Connecting to Your Pi via Ssh

Ok, we have the pi powered up, plugged in and have figured out its IPv4 address. Now we can log into it over the netwok using ssh, the secure shell. A shell is a command line interface to a computer (though, as we’ll see in a minute, ssh can be used to run graphical programs, too, and a lot else besides), and the secure bit in ssh’s name, rather unsurprisingly, means that all communication using it is encrypted.

Starting ssh is pretty straight forward:

ssh [options] username@remote computer

By default your Raspberry Pi has the username:pi and the password:raspberry. We don’t need to give ssh any options at the moment, so the complete command looks like this (though obviously you need to substitute my ip address with the one you found in the previous article):

ssh pi@10.42.0.68

As this is the first time the pi has been connected to, ssh will tell you that, “The authenticity of host [host name] can’t be established”. You don’t need to worry about this. This is caused by the chicken and egg problem of setting up secure communication, where you can’t identify a computer till you have connected to it the first time, but you can’t safely connect to it until you’ve identified it. There are really only two solutions to this problem. One is to manually add the identification of the new computer via some other means. The other is to just assume that the chances of someone trying to spoof being the computer you are about to connect to are very small and just trust it the first time (once you have connected to a computer once, ssh can ensure it is always the computer it claims to be), so seeing as it is very unlikely that someone is trying to spoof being the Raspberry Pi at this exact moment in time, it is ok to continue, so type “yes”.

Depending on how your local computer is set up, you may be asked for your passphrase or to set one up. The passphrase is an additional level of security that isn’t required. I’ll talk about it and why it is useful in more detail in a later post. In the meantime, if you have set up a passphrase, enter it; if you haven’t, don’t worry about it; if it asks you if you want to set one, leave it blank for the time being and hit “enter”.

It’ll then ask you for your password on the remote machine. As mentioned before, the default password on the pi is “raspberry”. Type it in and press enter. Be aware that, for security reasons, ssh won’t give you any feedback on the screen as to what you have just entered.

You’ll then be given some information about the system you have just logged into, including the useful advice to set up the pi using the command “sudo raspi-config”, so do that now, and we’ll look at the set up options in the next blog post.

3 Replies to “Connecting to Your Pi via Ssh”

I’m not sure what’s wrong. Accessing the Mac with ssh is allowed in the system settings (although I don’t know why it should help to access the mac with ssh..but anyway)
I opened the port 22 in the router (for mac and also for the pi).
Nothing worked so far. Any advice would be appreciated.