Roger Fan

Notes

High School Notes
University Notes
Computer Networking
Algorithm
Ch1 Algorithm Complexity and Sorting
Ch2 Greedy Method
Ch3 Divide and Conquer
Ch4 Tree Search Stategies
Ch5 Prune and Search
Ch6 Dynamic Programming
Ch7 The Theory of NP-Completeness
Computer Architecture
Operating System
Chapter 0
Chapter 1: Operating System Introduction
Chapter 2: OS Structure
Chapter 3: Process Concept
Chapter 4: Multithreaded Programming
Chapter 5: Process Scheduling
Chapter 6: Process Synchronization
Chapter 7: Deadlocks
Chapter 8: Memory Management
Chapter 9: Virtual Memory Management
Chapter 10: File System Interface
Chapter 11: File System Implementation
Chapter 12: Mass Storage System
Chapter 13: IO System
Discrete Math
Calculus
Calculus I
Calculus II
Linear Algebra
Probability
General Physics
General Education
Tech Notes
TMUX
SSH
Fail2ban
SSHD
UFW
DNS Bind9
Notes
Tech Notes
SSH

SSH

Created: 2025-11-30
Updated: 2025-11-30

SSH usage guide covering key generation, config setup, and security best practices for secure remote access

roger@roger.tw
roger@roger.tw
© 2026 Roger Fan. All rights reserved.

Basic Usage

  • key generation
    • ssh-keygen -t ed25519 -C "...comment..."
    • it'll generate a private key ~/.ssh/id_ed25519 and a public key ~/.ssh/id_ed25519.pub
  • copy public key to remote server
    • Method 1: Manual Copy
      • SSH into the remote server
      • Copy the public key, and paste it into ~/.ssh/authorized_keys
    • Method 2: Using ssh-copy-id to automatically copy the public key to the remote server
      • ssh-copy-id user@server_ip

SSH Config

Bash
# ~/.ssh/config
Host server_alias
  HostName server_ip_xxx
  Port 22
  User user_xxx
  IdentityFile ~/.ssh/id_ed25519
  ForwardAgent yes

# having this, macos will automatically use the keychain to store the passphrase
Host *
  AddKeysToAgent yes
  UseKeychain yes

Make server safer

  • Disable password authentication
    • Edit /etc/ssh/sshd_config on the remote server
      • PasswordAuthentication no
    • Restart SSH service: sudo systemctl restart ssh