Difference between revisions of "Setting up aliases to quickly log you in to a different machine"

From CUC3
Jump to navigation Jump to search
import>Csw34
import>Csw34
Line 13: Line 13:
 
alias cluster='ssh -X -C user@cluster'
 
alias cluster='ssh -X -C user@cluster'
   
Save and exit the file and then open a new shall. You should find that typing ''cluster'' will now connect you to the machine you specified! Of course, you still need to enter your password but we can automate that too using ''ssh-keygen'' which is dealt with in a different tutorial.
+
Save and exit the file and then open a new shall. You should find that typing ''cluster'' will now connect you to the machine you specified! Of course, you still need to enter your password but we can automate that too using ''ssh-keygen'' which is dealt with in a different tutorial. You can set up as many aliases as you want, and not just for using ''ssh'', you can make them execute any shell command!

Revision as of 15:43, 29 April 2008

Tired of having to type ssh -X -C user@cluster all the time to get onto your favourite machine? You could reduce all that down to a single, short shell command by using aliases!

For example, when I log into my workstation and open a shell, I can change machines to cluster by just typing

cluster

cluster is an alias I have defined in my .bashrc file, located in your home directory. You can't normally see it if you type ls but it's there.

To set up your own aliases, first open up your .bashrc file in your favourite editor i.e. vi

vi ~/.bashrc

And then add something like the following onto the bottom:

alias cluster='ssh -X -C user@cluster'

Save and exit the file and then open a new shall. You should find that typing cluster will now connect you to the machine you specified! Of course, you still need to enter your password but we can automate that too using ssh-keygen which is dealt with in a different tutorial. You can set up as many aliases as you want, and not just for using ssh, you can make them execute any shell command!