How can I run SSH on a port other than 22?

4

1

I have a Linux machine on my network. I connect to it using SSH with PuTTY over the Internet, so I have forwarded port 22 to the machine.

Now I need to put another Linux machine on the network. I will want to connect to this new machine using PuTTY as well. I want to run telnet/SSH on it using a port other than 22 so that I can forward it.

How can I make this happen?

TheVillageIdiot

Posted 2011-03-21T18:03:22.257

Reputation: 1 187

Having a duplicate on SF doesn't do much for those searching SU for the answer. – I say Reinstate Monica – 2019-10-22T21:20:37.163

It's not completely clear what you are asking. Are you configuring your ssh server or your telnet server? – Olli – 2011-03-21T18:14:30.017

@studio Off topic? – Daniel Beck – 2011-03-21T20:54:58.693

@DanielBeck: this was flagged as belonging on SF, and there is already a question like it (see peelman's comment above), so instead of migrating and having it closed there, I just closed it here... – studiohack – 2011-03-21T21:00:42.850

@studiohack I was confused about going to SuperUser or ServerFault. – TheVillageIdiot – 2011-03-22T03:45:43.300

Answers

4

It depends on your ssh server (and Linux distro).

Check out /etc/ssh/sshd_config (or similar, this is at least in Debian based distributions).

There is line

Port 22

Change it and restart your sshd (usually /etc/init.d/ssh restart, it may be also /etc/init.d/sshd).

Olli

Posted 2011-03-21T18:03:22.257

Reputation: 6 704

Noob comment, but if it's commented (# at the beginning), uncomment it (remove the #). BTW, works great! – Redithion – 2019-09-10T16:51:54.350

looks promising! – TheVillageIdiot – 2011-03-21T18:20:16.033

it worked like a charm! – TheVillageIdiot – 2011-03-21T18:40:55.173

1

You are running from outside of the network? (internet connection?) If not you don't need to forward port and just connect with ssh ip or ssh hostname (or equivalent using putty configurations). If you are out of the network and need port forwarding, you only need to edit /etc/ssh/sshd_config server file and change the #Port 22 line to the port you want and remove comment. After you need to restart ssh on the server.

laurent

Posted 2011-03-21T18:03:22.257

Reputation: 4 166

sure I am connecting over internet. – TheVillageIdiot – 2011-03-21T18:41:11.007