SSH configuration: override the default username [closed] SSH configuration: override the default username [closed] unix unix

SSH configuration: override the default username [closed]


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.


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

ssh buck@hostname

or

ssh -l buck hostname


man ssh_config says

User

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.