Quick overview of SSH

2 min read

The SSH protocol uses encryption to secure the connection between a client and a server. All user authentication, commands, output, and file transfers are encrypted to protect against attacks in the network.

Cliet Server Model

Public Key Cryptography

Signature

signature 確保資料傳輸的能符合

簡易流程如下

  1. 將要傳送的資料 hash 後,以 private key 進行加密,得到簽名 (signature)
  2. 將簽名與資料一同送出
  3. 收到資料與簽名後,以同樣的 hash 方式將資料轉為 hash value
  4. 透過公鑰解開簽名,比對步驟 3 的 hash value

Password Authentication

未將 client 端的 public key 加至 server .ssh/authorized_keys

ssh <username>@<remote_host>
# specify the port
ssh -p 2222 <username>@<remote_host>

Public Key Authentication

generating ssh keys

ssh-keygen -t rsa
# hit enter to put the key files in the default place
# hit enter to give an empty passphrase
# hit enter again to confirm

add the public key to server machine

mkdir ~/.ssh
vi ~/.ssh/authorized_keys # paste in client public key
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

connecting to server

ssh <username>@<remote_host>

Reference