These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/SSH

Classnotes | UNIX01 | RecentChanges | Preferences

ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. Unlike telnet, it runs across an encrypted connection. Across this connection, ports and applications can be forwarded and obtain the same level of encryption.

Under modern UNIX systems, ssh is rapidly replacing telnet as the default means for remote communication. It is generally more secure than telnet (although, a rather horrible bug in some earlier versions made it otherwise for a while).

The SSH server under Linux is typically called 'sshd', and under most Linuxes can be started and stopped by running it's init script

 # /etc/init.d/sshd {start|stop|restart}

There are some advanced sshd configuration options we will examine in UNIX03, but for most purposes the default settings by the Linux vendor will suffice.

SSH Clients

There are several client programs which you can use to connect remotely to an SSH server:

ssh

ssh is very similar to telnet. With it, you make a terminal connection with a remote machine. The basic syntax is as follows:
 ssh [OPTIONS] [REMOTE HOST INFORMATION]

The man page has it's full options. If you want to connect to a remote machine, then it may be as simple as

 $ ssh some.remotemachine.com

This will attempt to connect you to some.remotemachine.com as whatever user you are logged in locally as. If, however, you wish to log in under a different username, then you can use either of the following:

 $ ssh user@some.remotemachine.com
 $ ssh -l user some.remotemachine.com

If you wish to execute a command on a remote machine, you can follow your ssh line with that command

 $ ssh user@some.remotemachine.com command

scp

scp is essentially a secure copy clone for coping files to and from remote systems. Again, it has many options we will not cover here (see the man page), but the basic usages is as follows:
 scp [user1@system1:]somefile1 [user2@system2:]somefile2

For example, if I wanted to copy a local file index.html to a remote machine (geekcomix.com) and place it in the ~/www/classnotes directory on the remote machine, the command I would use would be

 $ scp index.html user@geekcomix.com:www/classnotes/.

I can also recursively copy across directories. So, if I wanted to copy the files in the directory ~/myfiles from server.com with the username "bob" locally to my machine, I could issue:

 $ scp -r bob@server.com:myfiles .

sftp

sftp is very much like any standard FTP client, except it operates over secure connections. It's usages is as follows
 $ sftp [OPTIONS] [user@][someserver:][/some/path]

So, if I wanted to make an sftp connection as user "frank" to the system "zyzzgy.net", I could issue:

 $ sftp frank@zyzzygy.net


Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 2, 2003 2:03 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.