Reputation: 621
I have an alias to a server machine:
alias myserver='user@server'
however, I cannot ssh into it by using the alias:
ssh myserver
ssh: Could not resolve hostname myserver: Name or service not known
the alias is correctly set:
myserver
returns bash: user@server: command not found
.
Obviously, it works when I do it extensively:
ssh user@server
what is going on? I am pretty sure it has been working until today... But not sure what I changed. Any help?
Upvotes: 1
Views: 3708
Reputation: 41327
Not sure about the alias, but I use ~/.ssh/config
:
Host myserver
HostName server
User user
Port 22
Then ssh myserver
is just like your alias for ssh user@server
.
Upvotes: 4
Reputation: 385
you can either have an Alias in your bash configuration which includes the actual ssh
command aswell ...
alias myserver='ssh user@myserver'
... or have an alias in your ssh config file.
Host myserver
HostName 10.10.20.20
User user
ssh myserver
should work.
A more extensive answer can be found for example here.
Upvotes: 4