OSU Navigation Bar

The Ohio State University

Department of Statistics

Cockins Hall
rollover image OSU Statistics
            Home

design element

OSU Statistics

Home

News

Research & Consulting Groups

People

For Visitors

For Prospective Students

For Current Students, Staff & Faculty

Contact Us



rollover image

For Current Students & Faculty

rollover image

Courses

rollover image

Links

rollover image

Computer Support

rollover image

Internal Documents

rollover image

webmail

Using SSH on Unix

Note: This information pertains to our Unix system only. It may be similar to other Unix systems, but it may not.

SSH1 vs SSH2

There are two standards SSH1 and SSH2. SSH1 is more common at this time and does not have the secure file transfer, sftp, built it. SSH1 and SSH2 are incompatible. We have both versions on our system, by default you get SSH2 commands, which have a fallback to SSH1 built in.

Using SSH for login

Basic use of ssh for logins is the same as telnet, except replacing the word telnet with ssh. For example, to ssh to an example host remotehost.edu, one would type ssh remotehost.edu. Then the remote host will prompt you for your password. If you are connecting to a host where you do not have the same user name you can connect as: ssh username@remotehost.edu.

The first time you connect to a host, it won't know the remote host's public key, and will prompt you with something like:

Host key not found from database.
Are you sure you want to continue connecting (yes/no)? 

You should type yes to this. The public key will be saved and you won't be asked this again. Except, if the other host's key changes, then you will get an ominous message about a 'possible nasty man in the middle attack'. While this is possible, it is more likely that the remote host's key was regenerated, due to an upgrade or reinstall of the SSH server. If you are really worried don't connect, but SSH is still better than telnet, since if they are able to hack SSH the hacker has surely hacked telnet.

Using SFTP for file Transfer

To connect to a remote host using sftp type sftp remotehost.edu. Then the remote host will prompt you for your password. (And may also give you the key message.) If you are connecting to a host where you do not have the same user name you can connect as: sftp username@remotehost.edu.

Once connected you will see an sftp> prompt. Here, you can type help for help, but all the commands are very similar to normal Unix ftp. Here's a summary:

  ls    get a directory of files on the remote host
  cd    change to a different directory on the remote host
  pwd   print the working directory on the remote host
  get   get a file from the remote host to the local host
  mget  get multiple files from the remote host to the local host
  put   put a file from the local host to the remote host
  mput  put multiple files from the local host to the remote host
  lls   get a directory of files on the local host
  lcd   change to a different directory on the local host
  lpwd  print the working directory on the local host

When done quit exits.

Using SCP for file Transfer

Although scp is available with SSH2, Sftp is much more intuitive than scp, and should be used if available. However, if the remote host only has SSH1, it will only have scp.

The syntax of scp is best shown by examples:
scp remotehost.edu:data_list .
this will copy the file data_list from the user's home directory on remotehost.edu to the current directory (.) on the local host. It will show a graphic of the transfer progress, and a summary of what it is doing.
scp remotehost.edu:/tmp/data_list .
this will copy the file data_list from the directory /tmp on remotehost.edu to the current directory (.) on the local host.
scp remotehost.edu:data_list data_list.new
this will copy the file data_list from the user's home directory on remotehost.edu to local host, renaming it to data_list.new.

Basically the syntax is similar to the Unix cp command, with the addition of the hostnames. As before, if the remote username is different on the other host, just add username@ before the command:
scp username@remotehost.edu:data_list .
And put a file to a remote host instead of get, simply reverse the arguments:
scp data_list remotehost.edu:.

Using X Windows through SSH

Assuming you are on an X capable terminal, like your workstation, when you SSH to a remote host SSH will automatically set your DISPLAY variable so that X connections go back through SSH.

X commands should just work normally at this point, without having to set your DISPLAY variable manually or xhost any machines. (Note, it is possible for other system administrators to not allow X tunneling. However, this is not the default and is rare.)



If you have trouble accessing this page, or need an alternate format contact webmaster@stat.osu.edu.