Make Alternative Port and User SSH Simple with ssh_config



  • Many of us, for one reason or another, have to log into servers via SSH using non-standard ports (other than 22) or a user that is not the same as the user on our local machine. This can be annoying, especially for scripting system access. But SSH has a simple fix for this, the ssh_config file.

    vi ~/.ssh/config
    

    This file is probably non-existent on your system if you have not used it before. So the vi command will create it now. Now for each host that we want to configure, we can just put in simple details like these:

    Host hostname
    Port 8022
    User altusername
    

    That's it. Now you don't have to specify a non-standard port for any server, just access it normally. Life is easy.



  • Just to clarify for others, everyone has an /etc/ssh/ssh_config file. Not everyone has it under ~/.ssh/.



  • I see new, greater, horizons of automation happening here.