Raspberry Pi – SSH Trouble

This weekend I reinstalled my Raspberry Pi with the Raspbian Jessie Lite image. Then I ran into some connections problems. Because I use the Raspberry pi Headless, I use use the SSH (Secure Shell) to access My Raspberry Pi from my Apple MacBook Air.

 

SSH is a secure network protocol. With an SSH connection, you can access your Raspberry Pi remotely from another device – whether that be a Mac, PC, or smartphone. Remote access to your Pi is especially handy if your Pi is acting as a web server – or as any kind of server, for that matter.

macOS

Establishing an SSH connection to the Raspberry Pi on macOS is very straightforward, since the operating systems comes with Terminal installed. You just have to open Terminal and enter this command:

ssh@your_ip_adress

After issuing the command, you’ll be prompted with a security alert. Type “yes” to continue.

Log in to your Raspberry Pi. If you’ve left the defaults unchanged, the username will be “pi” and the password will be “raspberry”.

You are now connected to your Pi and can control the device remotely with Linux commands. As mentioned in the Windows section, you can find a comprehensive list of Linux commands here.

 

 

Raspberry Pi – SSH Trouble

After executing the SSH connection, the following message appears on the screen.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5c:9b:16:56:a6:cd:11:10:3a:cd:1b:a2:91:cd:e5:1c.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for ras.mydomain.com has changed and you have requested strict checking.
Host key verification failed.
The Solution

To get rid of this problem add correct host key in $HOME/.ssh/known_hosts. You can try the following command to get rid of offending key. Only use the following commands if you have changed the ssh key or modified by new operating system installation or the recent OpenSSH server installation.

rm -f ~/.ssh/known_hosts

Now, you can connect to the host without a problem.