Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Pheak Pheasa
Pheak Pheasa

Posted on

     

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 pressingCtrl + Alt + T or by searching for "Terminal" in your application menu.

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

   ssh-keygen-t rsa-b 4096-C"your_email@example.com"
Enter fullscreen modeExit 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. PressEnter 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 pressEnter 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 modeExit 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 modeExit fullscreen mode

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

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Don't talk, just do it.
  • Joined

More fromPheak Pheasa

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp