I'm having some difficulties at the moment with my Ubuntu SSH server. The only title I could come up with summarizing my situation was too long so here is my problem:

I recently discovered the firewall "ufw" command on Ubuntu, now I am trying to configure so that when I use putty to connection via SSH to my Ubuntu OS, that I could only use a very specific port number and not the default port "22".

For some reason, I am being refused access on my newly chosen port. Since I'm still new to Ubuntu and networking, I don't quite understand what's wrong, any advice?

closed as too localized by Oli Aug 23 '12 at 10:12

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • I'm closing this because you resolved this yourself by noticing you made a couple of mistakes (as you pointed out in your comment below). – Oli Aug 23 '12 at 10:13

I guess you haven't allowed the SSH port in your ufw configuration. In the case where you have not done this, the port where SSH is running is blocked by the firewall. I guess you can't have remote access to your server...

If you have (physical) access to your server you can open the SSH port using following command:

sudo ufw allow <port number>/tcp 
  • No, I've already allowed my specific port number with the command you suggested. And I've also changed the port number in the file "/etc/ssh/ssh_config" – Armedan Aug 12 '12 at 18:41
  • Nevermind, but thanks for the reply. I've gone through everything again and here are the mistakes made: 1-I should have changed the port numbers in "/etc/ssh/sshd_config" and not in "/etc/ssh/ssh_config". 2-I did not restart the ssh server(i.e. sudo /etc/init.d/ssh restart) – Armedan Aug 12 '12 at 20:09
  • what about ipv6? – realtebo Jan 28 at 8:41
  • Worth noting, for those who find this later, there are two files: /etc/ssh/ssh_config /etc/ssh/sshd_config The first is for the client that connects to other computers. You want to change the one with the sshd, that "d" means Daemon (not demon) and is a program that waits for clients to connect to your server. Also worth noting that /etc/init.d/ssh restart actually does restart sshd, yes that's confusing. And to make things more current, Ubuntu 18.04 uses "sudo service sshd restart" to uh... restart sshd. (ufw still works the same, so the answer still applies). – Able Mac Jun 4 at 1:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.