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 [][1] or [][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!




Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s