Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im relatively new to Ubuntu, Im wondering how easy it is to write what I think is called a shell script to make tasks a little easier.

For example I frequently connect to a server - ssh -p 123

Can and how could I shorten this to a shorter command like "mysite" or "ssh mysite"


share|improve this question
up vote 6 down vote accepted

Alias is a quick and easy way, but a more secure one is to set up an ssh profile. In your ~/.ssh/config, put

Host mysite
Port 123
User me

Then you connect by just typing

ssh mysite
share|improve this answer
Perfect, thanks for your help. – jjodat Apr 6 '10 at 13:00

Maybe an alias in your shell is sufficient : alias mysite='ssh -p 123' Put that in your .bashrc (if your shell is the bash) and reload it by source .bashrc

share|improve this answer

For this particular case, you can add the following to the ssh config file (in ~/.ssh/config):

User me
Port 123

User otherme
Port 2222

This will shorten the command to ssh, which is not bad, and will also work with other programs relying on ssh (scp, sftp, many version control systems, etc)

You could go further and add a shorter hostname in /etc/hosts:

123.456.1.1   mysite

then replace by mysite in the other places.

share|improve this answer

Your Answer


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