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 *.dss.prefetch.net
ServerAliveInterval 60
User junior

Host *.ext.prefetch.net
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!

This article was posted by Matty on 2009-08-30 09:10:00 -0400 EDT