Using the ssh config file to set specify remote usernames

I periodically need to access remote systems using different userids (I didn’t have control over the account creation process, and unfortunately LDAP isn’t in use :( ). While I could use the username@host syntax to specify a userid, I find it easier to list the userids in the .ssh/config configuration file. Here is a sample configuration I use on one of my systems:

Host *
  ServerAliveInterval 60
  User rmatt

Host *
  Compression yes
  ForwardX11 yes
  IdentityFile ~/.ssh/id_dsa_ext
  User matty

The User directive can be applied to each Host configuration stanza, which allows you to specify a unique userid for each host (or group of hosts) you connect to. There are a number of cool SSH options, which are documented in the ssh_config(5) manual page. Nice!

Leave a Reply

Your email address will not be published. Required fields are marked *