Script Valley
Linux & Bash for Developers
Networking & SSH EssentialsLesson 5.2

SSH tutorial: connect to remote servers securely

SSH client usage, key pair authentication, ssh-keygen, ssh-copy-id, ~/.ssh/config, port forwarding, ProxyJump, SSH agent

SSH Is Your Primary Tool for Remote Server Access

SSH (Secure Shell) creates an encrypted tunnel to a remote server. Password authentication is enabled by default on most systems but key-based authentication is far more secure and convenient โ€” no password prompts.

Generating and Deploying SSH Keys

# Generate an ED25519 key pair (modern, preferred)
ssh-keygen -t ed25519 -C "your@email.com"

# Keys are saved to:
# ~/.ssh/id_ed25519      (private key โ€” never share)
# ~/.ssh/id_ed25519.pub  (public key โ€” safe to share)

# Copy public key to remote server
ssh-copy-id user@192.168.1.100

# Now connect without password
ssh user@192.168.1.100

~/.ssh/config for Shortcuts

Defining host aliases in ~/.ssh/config saves you from typing long hostnames and options repeatedly.

# ~/.ssh/config
Host prod
  HostName 203.0.113.5
  User ubuntu
  IdentityFile ~/.ssh/prod_key
  Port 22

Host staging
  HostName 203.0.113.6
  User ubuntu
  ProxyJump bastion

# Now just type:
ssh prod
ssh staging

Port Forwarding

# Forward local port 8080 to remote port 80
ssh -L 8080:localhost:80 prod

# Access a remote service at http://localhost:8080
# Remote port forwarding (expose local service to remote)
ssh -R 9000:localhost:3000 prod

Up next

Transferring files with scp and rsync

Sign in to track progress

SSH tutorial: connect to remote servers securely โ€” Networking & SSH Essentials โ€” Linux & Bash for Developers โ€” Script Valley โ€” Script Valley