Tuesday, July 20, 2004

SSH Secure Copy/ File Transfers

This follows on the ideas I've been putting out about using SSH in the everyday environment of an Administrator. The next use for SSH is to transfer files across a network, either from a remote machine or to a remote machine. SCP (Secure Copy), the SSH version of rcp, can transparently and securly copy files over the SSH protocol. With SSH you can also cpy between two remote systems without having to go through the local machine.

A good reason to transfer files via SSH is to move log files or configuration files from one machine to another machine. A nice added feature of SCP is that jobs can be automated with a Cron job. A key feature of the automated option is that public keys needs to be set up which I'll cover in another day or two.

The basic command looks like this: scp user@remotebox:~/
This will transfer the file listed in file name from the remote box to the local box. The colon after the remote box tells scp where to copy the file to. The ~/ lists the destination on the local box where to copy the file to, the default is the home directory of the user signed in with SSH.

Changing the order of the command will give a different result. Changing the order as thus: scp user@remotebox: /tmp/special This command will copy the file from the user's home directory on the remote machine to the /tmp/special directory on the local machine.

Relative file names resolve differently on the local machine than on the remote machine. On remote machine the /HOME directory is assumed, on the local machine the current directoy is used.

Some common options are:
-p option preserves modification times, access times, and modes from the original file.
-r recursively copy directories

When you specify remote locations in the source and destination, scp will copy from the source to the destination without going through the local host.

To return to the main directory for the SSH tutorials.

Monday, July 19, 2004

SSH Overview

SSH was created by Tatu Ylonen in 1995, OpenBSD picked up on the project in Dec 1999. SSH is intended as a complete replacement of the r utilities (rlogin, rsh, rcp, etc) and telnet. SSH focuses on securing network applications, such as terminal sessions.

SSHd is configured with the /etc/sshd_config file. This file can be used to configure such things as allow/deny hosts, idle timeout, and the type of authentication to be used. SSH reads the $HOME/.ssh/config file and the /etc/ssh_config when it starts up. Any configuration which needs to be done is accomplished with these three files, also the MAN pages will have more information about the SSH program.

The basic command to use SSH is:
ssh -l user@hostname

This will initiate the commands to log in. With SSH2, SSH splits the SSH functions into three separate protocolsusing the Transport Layer Protocol, Authentication Protocol, and the Connection Protocol. More information about the specifics of theses protocols can be found at the Information Security web site. This article has a good overview of the differences between SSH1 and SSH2.

Once a connection with the remote computer is established then commands can be executed and the results will be returned to the same terminal screen. This brings us to having a connection and being able to run commands remotely. The next couple of days I'll look at secure copying of files, authentication and using Public Keys.

To return to the main directory for the SSH tutuorials

SSH tutorial

For the next couple of weeks I want to cover the different aspects of the SSH program, along with some different uses for SSH. The topics I want to cover are as follows:
  1. Overview
  2. Secure Copy/ File Transfers
  3. Public Keys
  4. Configuration Files
  5. Compression
  6. X11 Forwarding
  7. Port Forwarding
  8. Security
  9. Troubleshooting
  10. SSH Configuration Tips from the SANS Internet Storm Center
  11. SSH Security Warnings
  12. Protecting SSH using known_hosts hashing
  13. Mobile SSH@PhoneMag.com
  14. DenyHosts, an SSH Server Attack Denial Tool
  15. SSH Tunnelling in Hotspots for Privacy
  16. ssh_blocker
Hopefully I can cover most of the uses of SSH for the average Sysadmin to uses SSh in their everyday environment.