So, I am setting up an ssh server. I have installed the ssh-server program on my server. However, I didn't want to connect to it through port 22, because reasons, so I set the server to listen through another port (2584). How do i set up my client to also connect through port 2584 rather than port 22?


2 Answers 2


Assuming you are using normal ssh command it is the additional parameter -p (see the man page of man ssh). E.g:

$ ssh -p 2584 user@host
  • 1
    Thanks so much! This worked! Now I dont have to use teamviewer...
    – user842910
    Jan 16, 2019 at 16:31
  • I can't, I am a new user, and my upvotes are not displayed.
    – user842910
    Jan 17, 2019 at 1:45

Note that ssh accepts commands in the URI form, such as ssh://[email protected]:<port>. It is perfectly valid to do the following:

ssh  ssh://myuser@domain_name.com:2222

Alternatively, to avoid specifying port each time, you can declare it within ~/.ssh/config. See steeldriver's answer for details.