Controlling Other Machines with SSH
Secure Shell (SSH) is a protocol used to securely access and operate computers across a network.
It’s based on asymmetrical cryptography. During the handshake, remote machines sign some session data—shared with the client—with their private key. This lets the client verify the signature using the remote machine’s public key, which is a known key. This process is similar to TLS certificate verification (Chapter 7, Securing Protocols: TLS). Optionally, the server can then require the client to provide a password to authenticate itself, or it can perform an inverse public/private key verification with the private key of the client. In the latter case, administrators or other trusted parties store the public key of allowed clients somewhere on the remote machine, which can then verify something signed by the client’s private key to confirm its identity.
Okay, we’ve covered authentication. But secure communication definitely requires encrypting in-flight data as well. SSH doesn’t rely on TLS for that. Instead, it generally uses plain old TCP as a transport and implements its own encryption layer.
The good news here is that Erlang has built-in support for SSH through the ssh application and its main ssh module.
| Wow, This Erlang Documentation |
|---|
|
| The Erlang documentation we just linked to is a treasure trove of useful and interesting information about SSH. It contains an overview of the protocol, practical examples, and more. |
Let’s take a quick look at how to use it.