Quick Tutorial on Secure Remote Logins and File Transfers

Jul 20, 2004

Secure Shell (SSH) and Secure Copy (SCP) are important alternatives to the less secure Telnet and FTP. Because Telnet and FTP do not encrypt their passwords, these programs can become security hazards. SSH will give you an encrypted data stream for remotely logging into your Linux box while SCP will allow you to transfer files in an encrypted environment.

Most distros already have SSH and SCP installed- if for some reason yours does not, check your package manager to install it.

SSH:
First, make sure the SSH daemon is running on your box:

[root@debian:/home/pibby]# pgrep sshd
11623

Note: pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. Your process number will be different from mine- we are only concerned with the fact that sshd is running. If you receive no output then you need to start it manually.

To start or stop SSH/sshd in Debian:

[root@debian:/home/pibby]# /etc/init.d/ssh start
Starting OpenBSD Secure Shell server: sshd.
[root@debian:/home/pibby]# /etc/init.d/ssh stop
Stopping OpenBSD Secure Shell server: sshd.

Logging into the Remote Box
The basic form of logging in consists of the command ’ssh’ and the ‘username’ of a user on the ‘hostaddress’:

[pibby@debian:/home/pibby]$ ssh username@hostaddress

For the purpose of the tutorial I will be using the username ‘user’ on ‘192.168.1.100′ (indicating a computer on my home network). The host address could be the IP of the remote computer, a domain name, etc.

[pibby@debian:/home/pibby]$ ssh user@192.168.1.100

In the event that SSH is not running on it’s usual port 22, you can specify the port like this (-p #):

[pibby@debian:/home/pibby]$ ssh -p 8181 user@192.168.1.100

When you first login, you will likely be presented with a message similar to the following:

The authenticity of host ‘192.168.1.100 (192.168.1.100)’ can’t be established.
RSA key fingerprint is d2:b2:ce:4a:01:33:e8:47:ca:3d:4d:c5:e5:60:d3:16.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.1.100′ (RSA) to the list of known hosts.
user@debian_linux:~$

You are now securely logged onto your Linux box!

SCP:
Unlike FTP, SCP does not allow anonymous downloads. SCP requires a username and password and provides a secure, encrypted environment for transferring files. SCP runs on the same TCP port as SSH, so if SSH is running then SCP will be running as well.

The basic format for copying a file from a remote computer to your computer is:

[pibby@debian:/home/pibby]$ scp username@hostaddress:remotefile localdirectory
[pibby@debian:/home/pibby]$ scp user@192.168.1.100:/home/user/file.txt /home/pibby/files/

If you need to specify a different port (-P #)- notice that a capital P is used in SCP, lowercase in ssh:

[pibby@debian:/home/pibby]$ scp -P 8181 user@192.168.1.100:/home/user/file.txt /home/pibby/files/

The basic format for copying a file to a remote computer from your computer is:

[pibby@debian:/home/pibby]$ scp localfile username@hostaddress:remotedirectory
[pibby@debian:/home/pibby/pictures]$ scp picture.jpg user@192.168.1.100:/home/user/files/

If copying multiple files simply list them all with a space between:

[pibby@debian:/home/pibby/pictures]$ scp picture.jpg picture2.jpg /home/pibby/Desktop/picture3.jpg user@192.168.1.100:/home/user/files/

That’s all there is to it!

Well that concludes my quick tutorial on SSH and SCP. For more information please read the man pages for these programs ‘man ssh’ and ‘man scp’ or check out http://www.linuxquestions.org

Leave a Reply


About Me

Katie DixonHello! My name is Katie, I'm 26 and from Houston, TX. I am a hardworking and passionate freelance web designer with a degree in eBusiness Web Development who creates clean and professional looking websites of the highest quality. I specialize in standards-based XHTML and CSS web development. The sites I develop are built to be search engine friendly!

You can find me on Twitter at @pibby for my latest updates. I am an avid computer user and my OS of choice is Mac OS X. I am most happy at home with my loving fiance', Drew, and our two loud but adorable dogs, Toby and Shelby.


Search


Archives



Pages


Contact Me

Phone: (281) 374-4780
Email: KatieDixon [at] gmail · com