- Install OpenSSH on your computer and all of the servers (You probably have done this already).
sudo apt-get install openssh-server
- Generate your public and private keys. When it asks for a passphrase leave it empty.
ssh-keygen -t rsa
- You now need to distribute your public key (~/.ssh/id_rsa.pub) to each servers .ssh/authorized_keys file. This can be done in several ways.
- If you have not made the authorized_keys file on the server you can do this:
scp ~/.ssh/id_rsa.pub username@servername:.ssh/authorized_keys
- If you have other entires in the authorized_keys folder then you can use cut and paste between two text editors. Open ~/.ssh/id_rsa.pub in the text editor of your choice on your computer. Open a normal SSH session on the server and open the ~/.ssh/authorized_keys in nano, vi, or any other terminal text editor. Copy the text straight from the text editor on your computer to the terminal window. Make sure that it ends up as one line in the authorized_keys file.
You can even set this for other users on the server as well as the root user. It is considered a bad practice to log in as root unless you are doing serious administrative tasks. If you run into problems after copying your public key onto your server, just simply move your keys out of your .ssh folder and then you can login to the server using your password to fix the issue. In that case make sure that your public key was all on one line.
No comments:
Post a Comment