Reputation: 751
I have my Mac setup with username XXX. And when I do my job, I need to ssh/scp to a remote server with username YYY (I use iTerm 2 and bash shell).
It's really annoying to specify the username YYY@hostname each time I login to the workstation, since the YYY is long (12 characters).
Is there any solution to change/specify the default user name from XXX to YYY of the shell, without changing my Mac username?
Upvotes: 0
Views: 8073
Reputation: 207708
Edit the file $HOME/.ssh/config
, and add something like this:
Host HOSTNAME
User YYY
Replace all the upper case parts. Now you can just do ssh HOSTNAME
and it will use YYY as the username.
To have this apply to all hosts that you use with SSH, you can do:
Host *
User YYY
And also, if you want to specify a shortened hostname with the ssh command, you can:
Host YOUR-NAME-FOR-THE-HOST
HostName ACTUAL-LONG-HOSTNAME-WITH-DOMAIN-NAME
User YYY
Then you can just run ssh YOUR-NAME-FOR-THE-HOST
and it will connect to the full hostname you specified.
Upvotes: 4