DEV Community

Pheak Pheasa
Pheak Pheasa

Posted on

3

To generate an SSH key in Ubuntu

To generate an SSH key in Ubuntu, you can follow these steps:

  1. Open the Terminal: You can do this by pressing Ctrl + Alt + T or by searching for "Terminal" in your application menu.

  2. Generate SSH Key: Use the ssh-keygen command to generate a new SSH key pair.

   ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter fullscreen mode Exit fullscreen mode
  • -t rsa: Specifies the type of key to create (RSA is the most common).
  • -b 4096: Sets the key length to 4096 bits for added security.
  • -C "your_email@example.com": This is a comment to help identify the key, typically using your email.
  1. Save the Key: After running the command, you’ll be prompted to choose a location to save the key. Press Enter to accept the default location (~/.ssh/id_rsa), or specify a different location.

  2. Set a Passphrase (optional): You will be asked to enter a passphrase. This adds an extra layer of security to your key. You can press Enter if you don't want a passphrase.

  3. View Your SSH Public Key: After the key is generated, you can display the contents of the public key file.

   cat ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode
  1. Copy the SSH Key to a Server (if needed): If you are setting up SSH keys for server access, you can copy the public key to the remote server using:
   ssh-copy-id user@server_ip
Enter fullscreen mode Exit fullscreen mode

After following these steps, your SSH key will be set up and ready to use for authentication.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay