Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The short question is that I'd like to know if it is possible to give ssh connections 'friendly' names in terminal?

My long reasoning is...

I've got several server clusters running behind a single IP address via NAT. I can SSH into the individual servers in each cluster with different port numbers e.g:

ssh clust1 -p 2210
ssh clust1 -p 2220
ssh clust1 -p 2230

In Putty/Windows I would give each connection a different name (clust1-web1, clust1-web2, clust1-web3), but in Terminal I cannot see a way to do this. This poses a problem because I cannot differentiate the server I'm connecting to by hostname, and the port numbers are somewhat random.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Run this from the terminal:

nano ~/.ssh/config

and then you can insert your hosts like so:

Host clust1-web1
        Hostname clust1
        User Username
        Port 2210

Host clust1-web2
        Hostname clust1
        User Username
        Port 2220

Then you can ssh by simply running:

ssh clust1-web1

For a full list of arguments you can place in this file you can run:

man ssh_config
share|improve this answer
    
Awesome, thanks so much :D –  James Napier Dec 23 '13 at 10:48

it's not quite the same but you can save each connection command as an alias.

Or if you some how can't do it this way, just store each connection command as a shellscript/bashscript perhaps named connect-clust1-web1 and store those in a folder which is also in your PATH

so you're able to just type connect-clust1-web1 and you'll get connected.

share|improve this answer

You can configure aliases in your ~/.ssh/config:

Host clust-web1
Hostname clust1.somedomain.tld
Port 2210

(etc)

Then, you can ssh to that host using the alias:

ssh clust-web1
share|improve this answer

Your Answer

 
discard

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.