This page contains tutorials to help Environmental Resources Engineering (ERE) students become familar with Secure SHell (SSH) and Secure File Transfer Protocol (SFTP) using a command terminal. The tutorials presented use the Cygwin terminal but should also be useful for MinGW, Linux terminal, or Mac OS terminal with openSSH installed. This tutorial assumes the reader is familiar with VIM editor basics.

Two sections are contained on the page:

Notes:

SSH Tutorial for ERE Majors

Secure SHell (SSH) is a utility for logging into a remote server and performing command line tasks. For ERE students, SSH will likely be used to log into the ERE server to edit, compile, and execute Fortran programs. This tutorial will walk through the steps needed to perform these tasks using Cygwin. See the Cygwin Installation Tutorial if you have not already installed Cygwin and the recommended packages.

The following steps will be described:

  1. Logging into the ERE-server with SSH
  2. Creating a Project Directory
  3. Creating a Fortran Program
  4. Archiving the Project
  5. Ending the SSH Session

Logging into the ERE-Server with SSH

The login process requires that you specify your username and what server you want to log into. Let <user> represent your userhandle at Humboldt State. Type the following, using your actual username, at the command terminal

> ssh <user>@ere-ssh.humboldt.edu

The terminal should respond by requesting your password for the server. Enter your password. The terminal will not show any characters as you enter your password. Once entered, press the <Enter> key.

If you have never logged into the server before, SSH will ask you if you want to save the encryption key. If you trust the server, save the encryption key.

Once you successfully logged into the server, you should be able to use the ls command to see your remote files and directories:

Creating a Project Directory

Once you are logged into the remote server, you can use commands on the remote server the same way you would use commands sitting at the terminal. The following commands create a project directory and changes the active directory to the project directory:

> mkdir project
> cd project

Listing the contents should yield the following at your terminal:

Creating a Fortran Program

SSH can be used to edit, compile, and run Fortran programs. Type the following to open a F90 file in VIM:

> vim hello.f90

and write the following program:

Save and close the program. The program can be compiled and executed using the following commands

> gfortran hello.f90 -o hello
> ./hello

The following should result:

Archiving the Project

Once the project is complete, we may be interested in archiving its contents using the tar and gunzip utilities. By changing directories to above the project directory, we can tar-gunzip the entire directory:

> cd ..
> tar -czvf project.tgz ./project

The following should result:

Ending the SSH Session

When you are done working on the remote server, simply type exit to end the session.

SFTP tutorial for ERE majors

Unlike SSH, the Secure File Transfer Protocol (SFTP) utility is strictly for moving files between a local machine and remote machine. This task requires the ability to manipulate files on a local machine and remote machine. SFTP commands are limited to file structure query and manipulation commands. SFTP has adopted a strategy of specifying commands targeted at the local machine by preceding the command with the letter "l" (as in Lima). Commands targeting the remote server are the same as normal terminal commands.

The list of commands available to sftp can be found by typing help or ? after logging into the target server.

sftp> help

ERE students may use SFTP to download files from their HSU network drive (U-Drive) to their local machine. Conversely, SFTP can also be used to upload files from a local machine to the HSU network drive.

This tutorial contains the following sections:

  1. Logging into the ERE-server with SFTP
  2. Navigating to the local and remote project directory
  3. Getting the remote project archive to the local machine
  4. Putting local project files to the remote project directory
  5. Ending the SFTP session

 

Logging into the ERE-Server with SFTP

The login process requires that you specify your username and what server you want to log into. Let <user> represent your user-handle at Humboldt State. Type the following, using your actual user-handle, at the command terminal

> sftp <user>@ere-ssh.humboldt.edu

The terminal should respond by requesting your password for the server. Enter your password. The terminal will not show any characters as you enter your password. Once entered, press the <Enter> key.

If you have never logged into the server before, SFTP will ask you if you want to save the encryption key. If you trust the server, save the encryption key.

If you have successfully logged into the ERE-server, the command pwd will return your remote present working directory. The command ls will list the files on the home of the remote server. The command lpwd will list the local present working directory and lls will list the local files.

 

Navigating to the local and remote project directory

If you have not done so already, you can make the remote project directory by typing

sftp> mkdir project

To change the directory of the remote server, type

sftp> cd project

 

You can make the local project directory by typing

sftp> lmkdir project

To change the local directory, type

sftp> lcd project

 

Getting the remote project archive to the local machine

To get files from the remote server to your local machine, use the get command.

sftp> get hello.f90

 

Putting local project files to the remote project directory

To put files from local machine to the remote server, use the put command.

sftp> put hello.f90

 

Ending the SFTP session

When you are done working on the remote server, simply type exit to end the session.