Host foo
  HostName foo.com
  User specialuser
  IdentityFile /Users/XXX/.ssh/id_rsa

Host *
  User defaultuser

On most machines, my UNIX login user name is XXX. But on one particular machine, it is YYY, how to modify this above .ssh/config file so it can work on all machines?

link|improve this question

38% accept rate
feedback

1 Answer

up vote 0 down vote accepted

Try using the %u escape sequence, which expands to the current user's username:

Host foo
HostName foo.com
User specialuser
IdentityFile /Users/%u/.ssh/id_rsa

Host *
User defaultuser

Read under the IdentityFile section in man ssh_config for other escape sequences.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.