Indeed, I want to create another new guide for how to access a remote server using Public-Key Authentication. Why? Basically: I want to use my blog as a technology notebook for my own.
So, Let’s ask, Do you want to connect to your remote server through ssh without having to authenticate every time?. If the answer is yes, follow these steps:
- This setup is based on Ubuntu 11.10
- For this demo username is le-user and server name le-server.com
Create a public/private key for your hosting server in your local computer. In a terminal go to you
.ssh folder and execute
- For the question Enter file in which to save the key, enter this name le-server.com.key or whatever name you like.
- For questions related to passphrase, leave it in blank, only hit enter.
luis@myblog:~$ cd .ssh
Copy generated key to your hosting server. Execute
ssh-copy-id -i le-server.com.key email@example.com. (It will prompt you to enter your hosting user password)
luis@myblog:~/.ssh$ ssh-copy-id -i le-server.com.key firstname.lastname@example.org
In your computer, in the folder .ssh open or create a filename called config and add the following peace of code at the end of the file
ssh-add ~/.ssh/le-server.com.key. This will add the private key to the SSH agent so that you will be prompted for the passphrase only once.
From your local computer. Open a terminal and just type
ssh le-server.com and voila!
luis@myblog:~$ ssh le-server.com
Happy coding :D