examples:

ssh dopey.usu.edu
ssh me@dopey.usu.edu

To run a command on wolf
ssh wolf ls
If the command you are running needs a terminal specify "-t"
ssh -t wolf /usr/sbin/sendmail

sftp dopey.usu.edu
To login into a specific directory with sftp
sftp dopey.usu.edu:public_html

scp file dopey.usu.edu:public_html/
To recursively copy a directory
scp -r fred wolf:public_html/

options:

-X : turns on xforwarding allowing you to run X applications over ssh

(-x turns X-Forwarding off, -X turns it on)

neat tricks:

while in an sftp session use ! to excute a command on the local machine

with xforwarding on you can run x(gui) commands on the remote machine and have them displayed locally.

Public Key Authentication

ssh-keygen

Generates a public/private key pair to be used for authentication.

common usage:
ssh-keygen -b 1024 -t rsa
or for DSA
ssh-keygen -b 1024 -t dsa

DSA vs. RSA
Basically RSA is faster for the server, slower for the client, and DSA is faster on the client, slower on the server. Equally Secure.

This will create:
~/.ssh/id_rsa and ~/.ssh/id_rsa.pub or
~/.ssh/id_dsa and ~/.ssh/id_dsa.pub

Next, you'll need to scp your id_rsa.pub or id_dsa.pub to the remote machine. then you'll need to append it to the end of your ~/.ssh/authorized_keys file. i.e. on the remote machine:

cat id_rsa.pub >> ~/.ssh/authorized_keys or for DSA

cat id_dsa.pub >> ~/.ssh/authorized_keys

Now you should be able to login using the passphrase for your private key instead of your password on the local machine.

ssh-agent and ssh-askpass

For security reasons, your passphrase should be fairly long, and it can be a pain to type it in repeatedly for several ssh sessions. Never fear, ssh-agent to the rescue.

in my .xsession, I have:

eval `ssh-agent -s`

ssh-addkey ~/.ssh/id_dsa &

The reason that I have it my .xsession, is that way the ssh-agent environment variables are present throughout my X session.

ssh-askpass is an X11 Program to ask for your passphrase. If ssh-addkey can't find it or find your display, it will just ask on the command line.

2005-02-18T14:56:19