Workings of a Virtual Private Network, Part 1
Public-key cryptography is the historical successor to secret-key cryptography. I call them two-key and single-key cryptography. Early ciphers used the very same key to decrypt as to encrypt. When sending a recipient your scrambled message, you must somehow also supply him your key to enable unscrambling.
The Achilles heel is that you may not supply the key using the same communications channel you are trying to secure. By presupposition, it needs securing—information on it is available to others. Others' inability to penetrate the scrambled messages you plan to send relies on keeping your key secret from them. But if you send it over that channel to your intended recipient, you are in effect sending it to others too, defeating your purpose. The term “secret-key” for this type of cipher reflects its requirement for keeping the key secret so it can work.
With public-key cryptography, there are two keys: a scrambler and a mathematically corresponding unscrambler. A person never gives out the unscrambler. Instead, he distributes the scrambler. Unlike a secret key, it doesn't unscramble anything. It doesn't possess the ability or value of unscrambling power. Therefore—drum roll—it's okay if it gets publicly intercepted.
Also, the parties—sender/encryptor and recipient/decryptor—reverse roles. The recipient-to-be, not the sender, generates the keys. And he, not the sender, distributes the necessary (scrambler) key to the other person. Security comes from the fact that the “power” key—the unscrambler—reposes from the start with the recipient where it's needed and never needs to travel. Transmission risk is thereby eliminated. Achilles heel solved.
Now let's see how ssh uses public-key cryptography for RSA authentication, and how it handles encryption. It has a utility, ssh-keygen, that generates matched key pairs and writes them into disk files. Typically, each user who wishes to use ssh/sshd will generate his own key pair, whether actively by running commands on other computers or passively by having users from other computers log in with his user name to run commands. ssh-keygen writes the two key-files into the logged-in user's home directory. The file identity.pub contains the public key suitable for distribution to others and is pure ASCII. The file identity contains the private key to be kept secret. A user runs ssh-keygen only once. Table 2 is the layout of these and some other important ssh files (not all discussed here).
User authentication works as an interplay between users' key files. (ssh also offers host authentication, involving /etc/ssh/ssh_host_key, not discussed here.) I'm talking about the two users who are always party to an ssh connection. First, when you run ssh from the local machine, you are already logged into it as somebody. Second, with the -l option in your ssh command, you specify some target user on the remote machine as the operator there. I'll call these local-user and remote-user. Another key-related file in each ssh user's home directory is authorized_keys. To succeed, RSA authentication must find a copy of local-user's public key embedded in remote-user's authorized_keys file. This will never happen except deliberately. If I, as the local-user, want to be able to log into your machine as you, I send you my public key. I could send you a copy of my identity.pub as a file, or embed its contents in an e-mail message (since it's pure ASCII and security of key transmittal is unimportant). You, the remote-user, will then place my public key into your authorized_keys file with an editor. Authorization will now succeed when I use ssh to log into your machine as you. Conversely, if I want to let you log into my machine as me, you'll send me your public key and I'll drop it into my authorized_keys file.
Authentication by sshd on the remote machine uses the local-user's public key to encrypt something and ship it back to local machine. Local machine must then prove itself by decrypting and sending back to the remote machine data matching the original. At that point, authentication is complete. sshd writes “RSA authentication for remote-user accepted” into the remote log (as above), and lets the session or command proceed. For implementation purposes, you simply need to follow the key prepositioning rules when configuring the computers to interact through ssh.
As we noticed earlier, this method doesn't involve any password. It cares only whether the “petitioning” user can convincingly come up with the expected public key and then demonstrate his possession of the matching private one. While it's counterintuitive, I routinely log into remote machines without a password—as root!
ssh offers other authentication methods, password checking among them (ssh is extensive, with many more options in its configuration files). These methods can be used instead of or in combination with RSA authentication. For purposes of a VPN, given that RSA authentication satisfies the test of adequate security for most, using it alone is preferred because of its transparency.
Webinar: 8 Signs You’re Beyond Cron
On Demand NOW
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.View Now!
|Non-Linux FOSS: All the Bitcoin, None of the Bloat||May 26, 2015|
|Dr Hjkl on the Command Line||May 21, 2015|
|Initializing and Managing Services in Linux: Past, Present and Future||May 20, 2015|
|Goodbye, Pi. Hello, C.H.I.P.||May 18, 2015|
|Using Hiera with Puppet||May 14, 2015|
|Urgent Kernel Patch for Ubuntu||May 12, 2015|
- Initializing and Managing Services in Linux: Past, Present and Future
- Non-Linux FOSS: All the Bitcoin, None of the Bloat
- Dr Hjkl on the Command Line
- Using Hiera with Puppet
- Goodbye, Pi. Hello, C.H.I.P.
- Gartner Dubs DivvyCloud Cool Cloud Management Vendor
- Mumblehard--Let's End Its Five-Year Reign
- It's Easier to Ask Forgiveness...
- Infinite BusyBox with systemd
- Urgent Kernel Patch for Ubuntu