Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

There are a few SSH destinations I will frequently be connecting to and I'm wondering if rather than remember the IP address I can create a host alias for them. I'd like to be able to use...

ssh -p xx user@domain.ssh

I've tried establishing this host in /etc/hosts and unless there's a service I needed to restart it had no effect.

share|improve this question
This should work fine. Paste the the entry in /etc/hosts file. Can you actually ping the host using the alias (if firewall is not block icmp)? – Terry Wang Feb 17 '13 at 23:02

1 Answer 1

up vote 23 down vote accepted

Sometimes it is more convenient to have configuration files in our home directory. This avoids having to be root to edit files, and also they can be configured in a way that other users have no access to these data. In addition this configuration will be backuped with our home and also will "survive" an OS upgrade

To do so we can make a ssh configuration file ~/.ssh/config where we can put in valuable information for a connection. A simple entry may have the following content:

Host myremote                 # any name for the host
    HostName   # IP, .local, or hostname if defined
    Port 22                   # port to listen

There are many other options including user and authentification you can give here (see manpage for ssh_config)

We then can simply issue the following to connect to on port 22:

ssh myremote
share|improve this answer
And I can sync it with Ubuntu One! Thanks! – Webnet Feb 22 '13 at 4:55
Note that you can also assign more than one host identifier, e.g. Host myremote That way your settings will be used when you connect using the actual host name as well. – Chris Aug 5 '13 at 5:39
Don't forget to add parameter 'User' (if there is need) into your config file! – Ros Nov 13 '14 at 10:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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