Create the key pair on the client machine
ssh-keygen -t rsa
Enter file in which to save the key (/home/shaan/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Public key will be located in /home/shaan/.ssh/id_rsa.pub Private key will be located in /home/shaan/.ssh/id_rsa
Copy the Public Key to server Copy the public key into the server's authorized_keys file with the ssh-copy-id command : ssh-copy-id user@host_or_ip
or series of commands :
Copy the contents of
~/.ssh/id_rsa.pub
into the file~/.ssh/authorized_keys
on the machine to which you want to connect.If the file
~/.ssh/authorized_keys
exists , append the contents of the file~/.ssh/id_rsa.pub
to the file~/.ssh/authorized_keys
on the other machine.
cat ~/.ssh/id_rsa.pub | ssh user@host_or_ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"Put the changes into effect by :
Restart SSH service
TROUBLESHOOTING
Check on local and remote servers, if OpenSSH is running
ssh -V
Check and set permissions of .ssh directory on remote server
chmod 755 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
Check and start the SSH Agent on local server, if not running
ps -ef | grep ssh-agent
ssh-agent $SHELL
Check SSH login to remote server from local
ssh -l username remote_host
No comments:
Post a Comment
Note: only a member of this blog may post a comment.