I'm trying to change the port number, and I've found a few answers on here from the past, most saying that you should use the following code.

nano /etc/ssh/sshd_config


modify /etc/ssh/sshd_config

The modify one (for me) comes back with a "Does not exist"/"Nothing found", and nano brings me back a blank page when people are saying it should have port numbers. Am I doing something wrong?

  • It looks like you don't have that file, did you already install openssh-server, so there is something to actually configure? – Mike Jul 17 '15 at 9:01

If the file comes up as blank when trying to edit using nano then the file is being created, as it doesn't already exist. This can also happen if you mis-type the filename.

To check whether the file is there:

cd /etc/ssh

Followed by:

ls -lh

This will output a list of files in the /etc/ssh directory. If the file doesn't exist, then you may need to reinstall, try:

sudo apt-get update && sudo apt-get install openssh-server
| improve this answer | |

Here's how you set up ssh.

You already have a ssh client with which you can connect to other machines. But if you want other systems to connect to you, you must install a ssh server like this:

sudo apt-get install openssh-server

Once you did that, edit your ssh congiuration file to change the port:

sudoedit /etc/ssh/sshd_config

Here nano is a command line based text editor. You should change Port 22 to the port which you want. To exit the editor, press Ctrl + X

Finally you need to restart the ssh daemon for the changes to reflect, so on 14.10 or older:

sudo service ssh restart

Or if you're running Ubuntu 15.04 or later,

sudo systemctl restart sshd.service

That's it!

| improve this answer | |
  • Ooh, even stevens on rep points! I've got to +1 for such a complete answer though! – Arronical Jul 17 '15 at 9:13
  • @Arronical Your answer is to the point. But the OP seems a little inexperienced. So I thought of writing one like this. – daltonfury42 Jul 17 '15 at 10:01
  • service isn't going to cut it if OP is using systemd (15.04 onwards) – Squidly Jul 17 '15 at 11:50
  • 1
    Use sudoedit instead of sudo nano. – Martin Schröder Jul 17 '15 at 13:24
  • 1
    Arronical, @daltonfury42 thanks both of you, I fixed it. And yes, daltonfury42 I am extremely inexperienced. My boss gave me a bunch of tasks to do with setting up ubuntu, writing codes in nano and bash when I had never even heard of these things before. Thank you guys so much. I couldn't decide who to put as the "Answer" because you both helped. – Brandon Jul 20 '15 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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