Home > Linux > SSH login using Public Key Encryption Part 1

SSH login using Public Key Encryption Part 1

Linux A –> Linux B

Do you find it annoying to keep entering password whenever you ssh to the commonly access linux server?
The solution is to use Public Key Encryption between the 2 linux machines.

On linux machine A: make sure you are using root access and cd ~/.ssh before running the following command.

ssh-keygen -t rsa -b 1024 -f MyKey

-t specify the type, in this case RSA (this depends on RSA Authentication parameter in sshd_config)
-b specify for bit length, in this case 1024  (has to be longer or equal with ServerKeyBits parameter in sshd_config)
-f key file name then, type the passphrase if you want one or just Enter for no-passphrase.

This will generate 2 files: MyKey and MyKey.pub.
Now we will need to export the public key to linux machine B, on Linux machine A:

ssh-copy-id -i MyKey.pub root@LinuxB

The public key from LinuxA will be stored in LinuxB ~/.ssh/authorized_keys

Categories: Linux Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: