Skip to content

Understanding SSH Protocol

SSH provides a secure way to connect to a remote server and execute commands. It uses encryption to protect the data in transit and provides a secure channel for remote access.

SSH supports multiple authentication methods, including password, public key, and keyboard-interactive.

SSH typically uses port 22 for secure remote access.

Generate SSH Keys

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

After this command, two files will be generated in the following location by default: ~/.ssh/id_rsa:

To copy the public key to clipboard, use the following command:

cat ~/.ssh/id_rsa.pub | pbcopy

Show list of SSH keys

ls ~/.ssh

or go to a location:

cd ~/.ssh

SSH Config File

SSH config file is a file that contains configuration for SSH clients. It is typically located in the ~/.ssh directory and is used to store connection information for remote servers:

nano ~/.ssh/config

Example of Config File:

# Global settings (optional)
Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

# Personal server shortcut
Host myserver
  HostName 192.168.1.100
  User myusername
  Port 22
  IdentityFile ~/.ssh/id_rsa

# GitHub shortcut
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519