I use ssh to get into a specific server on a specific port as normal:

ssh -p <port_number> <server_name>

How do I configure ssh to automatically use the right port number for a specific server, so that I don't have to enter the -p <port_number> parameter? Note different servers I connect to will have different port numbers.


Put it in your $HOME/.ssh/config file. For example:

Host bad.example.com
    Port 2222

Host *
    Port 22
| improve this answer | |

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.