SSH connections,... and forget about passwords!

SSH hodor

If you don't understand it, this blog is not for you

This guide is essential to our daily with SSH connections, but sometimes we become lazy (I'm the first).

I explain VERY EASILY how to generate keys you need so you don't have to write the damn password in each SSH connection.


Let's create the public/private keys and copy the first on the remote computer. Wrote the following from the computer where we are going to connect (in my case, a Mac):


cd .ssh
ssh-keygen -b 1024 -t rsa -f id_rsa -P ""
ssh pi@192.168.1.4 < ~/.ssh/id_rsa.pub 'mkdir -p .ssh && cat >> .ssh/authorized_keys'

OSX Terminal showing all the process. Click to enlarge

With the last command, we copy from our Linux/OSX the public key to the remote device. In this example, 192.168.1.4 (my Raspberry Pi).

END

It was not so hard, right?. Why have you don't this before?.

If you want to type less, create an alias in your Linux/OSX: nano ~/.bash_profile


Example: alias sshrpi='ssh pi@192.168.1.4'

And reload the shell with: source ~/.bash_profile

Now, every time you type sshrpi, will access from your computer to the Pi with no password.

Welcome.

smile


We request your permission to obtain statistical data on its navigation on this website. If you continue to browse we consider to accept the use of cookies. OK | More Information