ssh remote access
Programmers interacted with early computers through a terminal, an electronic keyboard and screen. Their shell read input from the terminal keyboard and printed output on the terminal screen (the earlier still teletype had no screen and printed output on paper like an electronic typewriter!).
These early computers had terminals that were inseparable from the computer they served. To use the computer, you had to use one of its dedicated terminals. These had to be physically close to the computer because of the connections available at the time.
The development of the Internet created the possibility of remote access using a network connection between your computer and the remote machine. The remote might be physically far away (in another room, building, city, or continent); lacking a keyboard and monitor (an embedded system like a Raspberry Pi); or a virtual machine with no physical existence.
The Secure Shell (SSH)
The Secure Shell Protocol (often abbreviated SSH) was introduced in 1995. It describes how to establish a secure connection between your computer and a remote machine over a network. The connection can be used to provide a command-line interface on the remote machine; to copy and manage files between your computer and the remote; or to perform other activities.
The SSH protocol and its related commands replaced earlier protocols like Telnet and the Berkeley r-commands. These transmitted data as plain text - including usernames and passwords. This was not a concern on small, early networks but became a serious security risk as the Internet was widely adopted.
Using SSH on your computer
It's likely that you already have SSH on your computer! The OpenSSH library
and commands are standard on Windows 10 (since version 1803); macOS (since
version 10.1); and nearly all Linux distributions. All you need to do is open
a terminal such as cmd.exe
or Terminal and
Using SSH on your computer
The best part of SSH is that it is likely already installed on your computer! The OpenSSH library of commands is standard on:
- Windows 10 (version 1803 and newer)
- macOS (version 10.1 and newer)
- Nearly all Linux distributions
To use SSH (including secure copy and
secure file transfer) all you need is a terminal such
as cmd.exe
or the Terminal app. You can use this to connect to
the cs-class server to start working with bash.
ARPANET - the first packet-switched computer network and direct precursor to the modern Internet - was conceived as a way to connect researchers to remote computing resources. Charles Herzfeld, ARPA director from 1965 to 1967, pitched the project thus: "I want every investigator to have a console ad their desk, where they can find all the tools, all the programs, all the data to do their work."
The first successful host-to-host connection on ARPANET happened on October 29, 1969. The World Wide Web would not exist until Tim Berners-Lee launched the first web server on December 20, 1990 - over 20 years later!
References
- McPherson, Stephanie Sammartino. Tim Berners-Lee: Inventor of the World Wide Web. Twenty-First Century Books, 2009.
- Schachtman, Noah. "How Pacific Island Missile Tests Helped Launch the Internet." Internet Hall of Fame, 27 Aug. 2012 ( link).
ssh
shell connections
You use the ssh
command to connect to a remote machine and run
commands (using a shell).
ssh
- remote login client
$ ssh [options]...
[user@]hostname [command]
The hostname
is a URL or IP address for the remote machine
you want to connect to. The user
is your username on that
machine. If you don't give a username, ssh
assumes its the same as
your local username (i.e., on the computer you're sitting at).
You can run a single command on the remote machine by typing it (along with its
arguments). If you type no command, ssh
begins a shell session so
you can type commands interactively.
Warning: Establishing authenticity of a new server
The first time you connect to cs-class (or any new server), you may see a warning like the following:
If you type "yes" (to accept the connection), the remote's identity is added to a known host file and you won't see the warning in the future.
If you regularly connect to a remote and the warning appears suddenly, be skeptical - this may be another computer pretending to be the remote to steal your login credentials!
After the network connection is established, you'll be asked to type your password to log in.
Warning: Password prompts in Linux don't move the cursor
When a Linux machine prompts you for a password, the cursor does not move while you type. This is a security feature to prevent prying eyes from seeing how many characters your password contains. Simply type your password as normal and press Enter to continue.
If you used ssh
to open a shell, you'll see your shell prompt on
the remote machine. You can type and run commands as if you were sitting at the
remote. When you're finished working, end your shell session by typing exit.
This will end the network connection and return you to your local shell prompt.
Example: Using ssh
to get a shell prompt on
cs-class
To get a shell prompt on cs-class, run the command below. Use your netID instead of mine (re268).
$ ssh re268@class-1.cs.georgetown.edu
You'll see the following paragraph describing the rules for access:
You'll be greeted by the following paragraph describing the conditions of access:
Type your netID password at the prompt. You'll then see a shell prompt indicating that you are connected and ready to work:
[re268@cs-class ~]$
The CS class server ("cs-class-1") is a Linux server can use while in a Georgetown CS course. You can access it remotely to get a bash shell prompt and work on assignments.
The class server is the target machine in many courses, meaning your programming projects are graded there. You'll want to be comfortable using bash there either to work on a project (say, with vim) or transfer code to/from the server (with scp and sftp to test and debug your homework.
The SSH config file
Programmers and system administrators regularly connect to multiple remote
machines, each with their own hostname, username, and other settings. You
can create "shortcuts" to remember your connection details using the SSH
config file. This is a plain text file found in your home directory at
~/.ssh/config
(note the dot in the directory name). You can use
a text editor to add or change configuration settings.
The config file is organized into sections (called stanzas). Each
section begins with a Host
line and may contain multiple lines
after. The indentations are not required, but make the file easier to read.
An SSH config stanza for cs-class
Host class-1
HostName class-1.cs.georgetown.edu
User re268
The Host
is a "nickname" that you choose. All following lines
are options or settings applied whenever you use that nickname. This lets
you type, e.g.,
$ ssh class-1
and the config file will expand this to
$ ssh re268@class-1.cs.georgetown.edu
You can add multiple stanzas (with their own Host
nicknames) to
remember settings for each remote machine you use.
You can specify many different settings in the config file. For a complete list with explanations, see the man page:
$ man ssh_config