GSSG


SSH Command Line Utilities Usage Examples

All of the following commands may prompt you for your password on the remote host.

SSH: Secure Remote Login and Command Execution

ssh is used to connect into a remote machine and for executing commands on a remote host.

syntax: ssh user@hostname [command]

Login to a remote host on which you have an account under the same user name as the host you're currently logged into:

ssh collie.stanford.edu

Login to a remote host on which you have an account under a different user name than the host you're current logged into:

ssh jhawkins@collie.stanford.edu

Run a command on a remote host on which you have an account under the same user name:

ssh collie.stanford.edu uptime

Run a command on a remote host on which you have an account under a different user name:

ssh jhawkins@collie.stanford.edu uptime

Use ssh with tar to move a directory of files between two machines as an alternative to scp:

tar -cvf - images/dogs | ssh jhawkins@collie.stanford.edu '(cd new_images; tar -xf -)'

SCP: Secure Copy

scp copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh.

syntax: scp [-r] user@host1:file1 user@host2:file2

Copy a local file to the login directory of a remote host on which you have an account under the same user name:

scp dogs.gif collie.stanford.edu:

Copy a remote file in a subdirectory to the local host (and current directory) on which you have an account under the same user name:

scp collie.stanford.edu:images/dogs.gif .

Copy a local file to a remote host on which you have an account under a different user name:

scp dogs.gif jhawkins@collie.stanford.edu:

Copy an entire local subdirectory to a remote host on which you have an account under the same user name:

scp -r images/dogs collie.stanford.edu:


Last updated 10/22/02
Questions, comments, additions and/or suggestions? Mail the webmaster.