Log in through SSH using a different username (the easy way)
There are two ways that i know to log in through ssh using a different username using the command line:
ssh username@server.yourdomain
or
ssh server.yourdomain -l username
The last one is my choice, and i know a lot of users did like the trinity’s scene (The Matrix), when she used that line too…
But if you need to login in many machines with different usernames, that can be a tedious choice. So, you can use some options in your ~/.ssh/config file:
1) If you have the same username in all servers on a specific domain, you can handle that domain with the following configuration in your ~/.ssh/config:
Host *.yourdomain1.com User userdomain1
With that configuration you can login in all machines in yourdomain1 using the username you have configured. Now, if you have another username on another domain, you can add that configuration too:
Host *.yourdomain2.com User userdomain2
Respecting the rules’ rule, you can configure an exception too. If there is a host in one of the configured domains that your account is different, you can configure it too (but it needs to be the first in order):
Host server9.yourdomain2.com User userserver9 Host *.yourdomain2.com User userdomain2
That’s all
just wanted to thank you for reminding me how the -l switch works with ssh.
I’m playing with the raspberry pi running a paired down debian variant called rsapian and I find the hostname can’t be resolved on my home network but using the 192.168.1.100 address from any of the other computers works like a charm.
Bob
Bob.
To login to the pi, or any other linux box on your network using the hostname, add:
192.168.1.100 your_raspberrypi_hosname
to your /etc/hosts file.