SSH (Secure Shell Protocol)

Robby Widyahartono
4 min readJun 11, 2021

Introduction to SSH
SSH is the protocol that allows us to communicate between two computers over the internet. It allows users to share files as well as control and modify remote computers over the internet. It provides several alternative options for strong authentication, and it protects the communications security and integrity with strong encryption.

SSH Command

ssh {user}@{host}

You can try using free ssh server for this. Usually, I use sdf for the ssh testing.

For Example :

ssh robbywh@tty.sdf.org 

We can create the test directory to the server with this protocol

SSH Encryptions technology

  1. Symmetrical Encryption

Symmetrical Encryption uses one secret key for both encryption and decryption. The process of creating a symmetric key is carried out by a key exchange algorithm. What makes this algorithm particularly secure is the fact that the key is never transmitted between the client and the host. Instead, the two computers share public pieces of data and then manipulate it to independently calculate the secret key. Even if another machine captures the publically shared data, it won’t be able to calculate the key because the key exchange algorithm is not known. This key exchange algorithm needs something called Asymmetrical Encryption.

2. Asymmetrical Encryption

Asymmetrical Encryption uses two separate keys for encryption and decryption. These two keys are known as the public key and the private key. Together, both these keys form a public-private key pair. Message that encrypted by machines public key, can only be decrypted by the same machines private key.

This form of encryption is actually only used during the key exchange algorithm of symmetric encryption. Each computer can combine their own private key with public key from other computer and generate the symmetric key with Diffie Hellman Key Exchange.

3. Hashing

One-way hashing is another form of cryptography used in Secure Shell Connections. One-way-hash functions differ from the above two forms of encryption in the sense that they are never meant to be decrypted. SSH uses hashes to verify the authenticity of messages. This is done using HMACs, or Hash-based Message Authentication Codes. This ensures that the command received is not tampered with in any way. Each message that is transmitted must contain a MAC, which is calculated using the symmetric key, packet sequence number, and the message contents. It is sent outside the symmetrically encrypted data as the concluding section of the communication packet.

Set up SSH on Github

  1. Go to .ssh folder
cd ~/.ssh

2. Add GitHub to the list of authorized hosts

ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

2. Generate public/private rsa key pair inside .ssh folder

ssh-keygen -t rsa -b 4096 -C “robby.widyahartono@gmail.com”

3. Copy ssh public key to the clipboard

pbcopy < ~/.ssh/id_rsa_github.pub

4 . Paste the ssh public key in Github SSH Settings, and add the SSH key

5. Use the ssh private key on your computer

ssh-add ~/.ssh/id_rsa_github

6. Now you can clone your repository with ssh command

git clone git@github.com:RobbyWH/nest-intro.git

--

--

Robby Widyahartono

I’m a Full Stack Typescript Engineer, I usually work with react native, react js, and NestJS