SSH configuration: override the default username [closed] – Dev

The best answers to the question “SSH configuration: override the default username [closed]” in the category Dev.


Is it possible to configure ssh to know what my username should be?

By default it uses the current username, which is not correct in my case.

I’m on a loaner laptop, and my username is loaner, but I want to tell ssh that my username is buck.

Bonus points: my username at home is bgolemon. If I could configure the username per-host that would be even better.


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

ssh [email protected]


ssh -l buck hostname


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

Host *
    User buck

Or add

Host example
    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; ssh example will be enough.


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

alias sshb="ssh [email protected]"

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:



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.