Secure Encrypted Communications Using OpenSSH

OpenSSH is an implementation of SSH (secure shell) which is used for secure communication between two machines (a client and a server). OpenSSH is the best tool you can use for secure data transfer. Below, we'll run through how you can start using it for your data transfer needs.


The server side of the communicting machines needs to be running sshd (secure shell daemon) which listens for and handles incoming connections. The basic usage for ssh is to allow execution of commands on a remote machine. It is also used to provide the underlying secure data transfer for both scp and sftp.
The program ssh (the client side of the connection) is installed by default in most linux distributions including Ubuntu. To see what version of ssh client you've got installed, run:

ssh -V
The server side (sshd) normally needs to be installed as it's not there by default. Below, we'll run through some basic usage of ssh, these assume the server side has sshd installed. See the installation instructions here.

Logging into a Remote Machine

To simply login to a remote machine, use:

ssh username@hostname

For example :
ssh tutonics@
You could also use:
ssh -l username hostname
For example:
ssh -l tutonics

Running a Remote Command

You can run a command on the remote machine using:

ssh username@hostname 'command1;commmand2'
For example to list files in the Download directory on the remote machine, use:
ssh tutonics@ 'cd ~/Downloads;ls'
Note that if you want several commands to execute on the other box, they must be within the quotes and separated by a semicolon as shown, otherwise only the first command will run remotely, the rest will run locally.

Running a Local Script on Remote Machine

If you have a script which resides on your local box (e.g. and you wish to run it on your server, use:

ssh username@server 'bash -s' <

SSH Client Configuration File

The ssh client configuration file is /etc/ssh/ssh_config. We'll cover some of these options in future ssh tutorials.

Thanks to Tatu Ylonen, Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song for their work with ssh.