Setup ssh key authentication for password-less login between servers. For use by ssh/sftp users or scripts.
Source Server (or local system)
Generate RSA key for user on this system, you can also use DSA. This asks for key pass-phrase but you can leave it blank.
ssh-keygen -t rsa
This asks for location to place the generated key, by default it will be your home directory (ex: /home/your_username/.ssh/). This generates two files: id_rsaand id_rsa.pub. Content of id_rsa.pub is what we need to copy to destination server.
Destination Server (or remote server)
Check if you have the directory .ssh on your home (ex: /home/username/.ssh/), if not, create that directory.
ls ~/.ssh
mkdir ~/.ssh
Check if you have existing file authorized_keys on your .ssh directory, if not create it.
ls ~/.ssh/ authorized_keys
touch ~/.ssh/ authorized_keys
Copy content of id_rsa.pub that you created from your source/local server, or execute this command from your source/local server:
scp ~/.ssh/id_rsa.pub username@remote_host:~/.ssh/authorized_keys
Test your password-less login from source to destination server.
No comments:
Post a Comment