Table of Contents
ssh (OpenSSH client program)
ssh
is OpenSSH's SSH client program used for logging in to a remote machine and for executing commands on it.
Installation
Ubuntu
4.10 Warty and above
All needed SSH client tools should be installed by default. Therefore everything you need to exchange data with a SSH server should be already there. If not (e.g. because it was removed), simply install the following package(s):
openssh-client
(main)
After installation, the SSH client is available via terminal: ssh
Usage
To connect as remote-user
to the system remote.example.com
, the command ssh remote-user@remote.example.com
should be sufficient to establish a SSH session. Just type exit
to close it afterwards:
user@client.local:~$ ssh remote-user@remote.example.com remote-user@remote.example.com's password: Linux 2.6.26-bpo.2-amd64 #1 SMP Mon May 18 17:15:45 UTC 2009 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Tue Jun 29 22:20:48 2010 from client.local remote-user@remote.example.com:~$ exit logout Connection to remote.example.com closed. user@client.local:~$
If the SSH session is not responding anymore (e.g. because the SSH server on remote.example.com
was unexpectedly shut down), the command ~.
closes the client.
The username is optional if it is the same on both systems:
user@client.local:~$ ssh remote.example.com user@remote.example.com's password: [...]
Additionally it is possible to execute a command and automatically close the SSH session afterwards by simply passing it as parameter (including pipes, stream manipulation etc.):
user@client.local:~$ ssh remote-user@remote.example.com cat /var/log/syslog user@remote.example.com's password: [...cat output...] user@client.local:~$
ssh
provides many useful options, a look at its manpage may be helpful.
Configuration
Tips and tricks
Close ssh if the SSH session is not responding anymore
If the SSH session is not responding anymore (e.g. because the SSH server was unexpectedly shut down), the command ~.
closes the ssh
client program.