Skip to content
Oliver Lantwin edited this page Oct 29, 2015 · 9 revisions

SSH stands for Secure SHell. It represent the most common way of connecting to remote machines in HEP. Most people are familiar with its basic usage but there are many techniques which will make your life a lot quicker and easier.

Tips

  • Use sshfs to mount remote drives as if they were local e.g. after creating a folder in your local computer home directory called 'lx_home':
sshfs -o workaround=rename remote_server_name:/home/hep/jbloggs ~/lx_home

where remote_server_name represents the full remote server name. This will mount your lx home directory such that it appears to be a local folder on your personal machine. The folder can be unmounted with:

fusermount -u lx_home
  • Use the config file. Creating a file called ~/.ssh/config allows you to create a great many labour saving devices, including host aliases, automatic tunnels and port redirections, keep alive pings, multiplexing, and so. See the links below for an introduction. A simple example:
# ~/.ssh/config
# A simple server alias
Host lx04
	HostName remote_server_name04
	User jbloggs
# A still simple alias for all lx0? machines
Host lx0?
	HostName %h.remove_server_name # %h substitutes host alias
	User jbloggs
# Set up a tunnel automatically to a remote server behind a gateway machine
Host gway
	HostName remote_gateway_name
	User jbloggs
	LocalForward localhost:7000 machine_behind_gateway:22
Host mbg
	HostName localhost
	Port 7000
	User jbloggs
	HostKeyAlias mbg

This would provide short aliases instead of the full long server name (recognised by both ssh and scp). Further, opening a ssh connection to the gateway machine, now aliased as gway, would then allow mbg (machine behind gateway) to be connected to as if the connection were direct (far easier than hoping from machine to machine).

  • Multiplexing allows sharing of the same TCP connection between multiple ssh connections. This means that after the initial login to the remote machine, all subsequent shells will no longer need a password to be entered, and scp will be able to perform tab auto-complete for paths. Add the following line to the top of your config file to enable it. A description is given in the multiplexing link below.
Host *
   ControlMaster auto
   ControlPath ~/.ssh/master-%r@%h:%p

An addition tip for multiplexing, when you run multiple SSH Sessions, all must be closed in order to close the first one (the one that started the multiplexing). To avoid this, you can start and SSH session in the background with the following command.

ssh -f -N -Y [email protected]

Links

Clone this wiki locally