unix - SSH configuration: override the default username

ID : 10283

viewed : 32

Tags : unixsshssh-configunix

Top 5 Answer for unix - SSH configuration: override the default username

vote vote


Create a file called config inside ~/.ssh. Inside the file you can add:

Host *     User buck 

Or add

Host example     HostName example.net     User buck 

The second example will set a username and is hostname specific, while the first example sets a username only. And when you use the second one you don't need to use ssh example.net; ssh example will be enough.

vote vote


If you only want to ssh a few times, such as on a borrowed or shared computer, try:

ssh buck@hostname 


ssh -l buck hostname 
vote vote


man ssh_config says


Specifies the user to log in as. This can be useful when a different user name is used on different machines. This saves the trouble of having to remember to give the user name on the command line.

vote vote


You can use a shortcut. Create a .bashrc file in your home directory. In there, you can add the following:

alias sshb="ssh buck@host" 

To make the alias available in your terminal, you can either close and open your terminal, or run

source ~/.bashrc 

Then you can connect by just typing in:

vote vote


There is a Ruby gem that interfaces your ssh configuration file which is called sshez.

All you have to do is sshez <alias> username@example.com -p <port-number>, and then you can connect using ssh <alias>. It is also useful since you can list your aliases using sshez list and can easily remove them using sshez remove alias.

Top 3 video Explaining unix - SSH configuration: override the default username