This may be trivial, but I am not sure how do it safely and optimally.

I have a few servers (AWS EC2) into which I ssh from the bash. Those server names are long.

How can I alias them, so instead of typing the long thing, I can type something like

ssh ubuntu@<alias-name>

1 Answer 1


This should work:

create a file $HOME/.ssh/config (or in /etc/ssh/ssh_config, if you want to install that alias system-wide), and put the following config inside:

Host myalias
    Hostname very-long-ugly-fqdn-hostname
    User ubuntu
    Port 22

after that, you are able to execute ssh myalias from any shell.

PS: of course, the setting Port 22 is not necessary, since it is default. but this is supposed to show, that you can put any valid ssh option in a Host definition.

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