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:
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.
To simply login to a remote machine, use:
For example :
You could also use:
ssh -l username hostname
ssh -l tutonics 192.168.0.7
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 email@example.com '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.
If you have a script which resides on your local box (e.g. myLocalScript.sh) and you wish to run it on your server, use:
ssh username@server 'bash -s' < myLocalScript.sh
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.