Changing SSH Port number on Raspberry Pi/Linux

Ssh (login remotely) into the RPi using Mac with the default port first. To do so, ppen a terminal and just type:

ssh pi@<ip assigned to RPi>

After entering your password:

sudo nano /etc/ssh/sshd_config

At about the 5th line of the file, change (of course you can change it to any port number you want to use. Check [www.iana.org][1] or [https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers][2] to find out which port number is available (or not):

#Port 22
Port 12345

Save the file by pressing Ctrl-X –> Y –> Enter

sudo service ssh restart
[ ok ] Restarting OpenBSD Secure Shell server: sshd.
pi@raspberrypi ~ $

Once you logout of your session, you’ll have use the following command to ssh into your Raspberry Pi:

ssh -p 12345 pi@<ip assigned to your Rpi>

Don’t forget to add/change your router’s SSH port if you want access your Pi remotely, like from outside of your home!

[1]: http://www.iana.org
[2]: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s