Tuesday, December 15, 2009

Using public-private key with ssh / scp

To avoid using the password for ssh and scp, public-private key can be setup.

The steps for same are as follows-
a public private key combination. Either use the following to create a fresh pair -
ssh-keygen -t rsa
or use the following to create a public key from existing private key
ssh-keygen -e > public_key.pub

Add the public key to the remote computer in the file - ~/.ssh/authorized_keys
The syntax should mirror -
from="*.example.org" ssh-rsa AAAAB3NzaC1…


The above should be in single line. Beware there might be other keys in the file.
Ensure that authorized_keys has access permissions set as -  600

Test that this works by calling -
ssh -o PreferredAuthentications=publickey server.example.org

For more details refer the link.

No comments:

Post a Comment