Linux Password Less Authentication (rsa key file)

From PedrosBrainDump
Revision as of 16:03, 7 November 2024 by 413vhcu1lq0463ob (talk | contribs) (Created page with "=== '''Generate the SSH key pair on your local machine''' (the one you want to connect from): === ssh-keygen -t rsa -b 4096 -f ~/.ssh/username * <code>-t rsa</code>: Specifies the RSA algorithm (you can also use <code>ed25519</code> for better security). * <code>-b 4096</code>: Sets the key size (4096 bits for RSA). * <code>-f ~/.ssh/username</code>: This option lets you set the filename and path for the key. Here, it will save the private key as <code>~/.ssh/username<...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Generate the SSH key pair on your local machine (the one you want to connect from):

ssh-keygen -t rsa -b 4096 -f ~/.ssh/username
  • -t rsa: Specifies the RSA algorithm (you can also use ed25519 for better security).
  • -b 4096: Sets the key size (4096 bits for RSA).
  • -f ~/.ssh/username: This option lets you set the filename and path for the key. Here, it will save the private key as ~/.ssh/username and the public key as ~/.ssh/username.pub.

Save the key files:

  • You’ll be prompted to choose a file location for the keys. Press Enter to accept the default path (~/.ssh/id_rsa).
  • You’ll then be asked to set a passphrase. Press Enter if you want passwordless login; otherwise, enter a passphrase for extra security.

you can manually copy the key:

scp ~/.ssh/username.pub username@server_ip_address:/home/username/.ssh/authorized_keys