FTP (File Transfer Protocol) was designed at a time when the number of servers on the Internet could be counted on one hand so it was never designed with security in mind. In those early days of the Internet, system administrators knew each other personally and trusted each other. Today, with dozens of millions of hosts on the Internet and with the number of people who have bad intent, it is no longer sufficient to rely on such antiquated protocols. One of the biggest problems of FTP, and what makes it particularly unsuitable for security-conscious system administrators and webmasters, is that authentication is done via login and password information sent as plain-text, i.e. not encrypted.
Today, no responsible webmaster would have users authenticating on a web site without using SSL (https) but many of them seem to be blissfully ignorant of the risks posed by sending FTP passwords in the clear. Fortunately, there is a good alternative, scp (secure copy), which is based on the ssh (secure shell) protocol. In our case, we will be using RSA PKI (Public Key Infrastructure) to secure the connection between your computer and the server. This is often referred to as "two-factor authentication". It relies on two things, something you know, a passphrase, and something you have, a private key. Even if an attacker was able to guess your passphrase, it would not do any good without having physical possession of your private key.
In this HOW-TO, we will generate an RSA public/private key pair, put the public key on the web server, use a key manager to manage your private key, and configure the client to take advantage of the RSA key based authentication. This eliminates the need for Dinamis personnel to send a password to you by insecure means, such as by e-mail, and for anyone but you to know the passphrase for your private key. Once you have your private key unlocked and being managed by the key manager, which runs on your computer, you can initiate as many sessions as you like without having to authenticate for each session.
The following HOW-TO outlines how to set up public key ssh authentication in order to transfer to and from your Linux web server in a secure fashion and also to get a secure shell to Linux. If you do no know what a secure shell is, you can ignore that capability.




Once you have received confirmation from Dinamis that your key has been received and added to the authorized_keys file on the server, continue with the following steps.






If you are running OS X and you do not already have a public/private key pair, you can generate a key pair by starting Terminal in OS X and typing the following.
ssh-keygen
You will see output like the following. When you are prompted for the file name in which to save the key, just hit return to accept the default. When you are prompted for the passphrase, enter something sufficiently complex that someone cannot guess it. You can manage this passphrase with keychain later.
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/cilkay/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/cilkay/.ssh/id_rsa.
Your public key has been saved in /Users/cilkay/.ssh/id_rsa.pub.
The key fingerprint is:
aa:92:77:5b:5f:90:38:47:57:c6:2b:e0:d5:90:e9:ab cilkay@ganges
The key's randomart image is:
+--[ RSA 2048]----+
| .*o |
| . +oo |
| ..+. . |
| o.oo . |
| S + o |
| . o .. |
| . . . .. |
| o .... .E. |
| o.... . |
+-----------------+
Copy your public key to a file with a meaningful name, e.g. jsmith.public.key. Obviously, substitute your name for "jsmith". That file will be placed at the root of your home directory.
cd
cp ~/.ssh/id_rsa.pub jsmith.public.key
Attach the public key (id_rsa.pub) to an email and send it as an email attachment to the person at Dinamis who requested the key from you. If you know how to digitally sign your email, all the better.
You will probably want to use some GUI client to do file transfers just like you may be used to doing with ftp clients. Fugu and Cyberduck are two good examples.
If you are running Linux and you do not already have a public/private key pair, you can generate a key pair by starting a shell and typing the following.
ssh-keygen
You will see output like the following. When you are prompted for the file name in which to save the key, just hit return to accept the default. When you are prompted for the passphrase, enter something sufficiently complex that someone cannot guess it. You can manage this passphrase with your key agent later.
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cilkay/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/cilkay/.ssh/id_rsa.
Your public key has been saved in /home/cilkay/.ssh/id_rsa.pub.
The key fingerprint is:
56:c0:da:83:d8:f6:36:86:dd:32:3a:12:bd:46:c7:ec cilkay@nile
The key's randomart image is:
+--[ RSA 2048]----+
| .. |
| .. |
| o + . |
| . = o. |
| o *So |
| . +.% . |
| o B + |
| . = E |
| o . |
+-----------------+
Copy your public key to a file with a meaningful name, e.g. jsmith.public.key. Obviously, substitute your name for "jsmith". That file will be placed at the root of your home directory.
cd
cp ~/.ssh/id_rsa.pub jsmith.public.key
Attach the public key (id_rsa.pub) to an email and send it as an email attachment to the person at Dinamis who requested the key from you. If you know how to digitally sign your email, all the better.
There is no shortage of GUI scp and SSHFS clients for Linux.