How to Connect via SSH
to Any Remote Server
From your first ssh user@ip to key-based login, config shortcuts, and file transfers — everything in one place.
What is SSH?
SSH (Secure Shell) is a cryptographic network protocol that lets you control any remote machine securely — as if you were sitting right in front of it. It runs on port 22 by default and encrypts all traffic end-to-end.
Whether you are a web developer deploying code, a sysadmin managing servers, or someone controlling a Raspberry Pi from home — SSH is the tool you need.
Encrypted Transport
All data encrypted with AES or ChaCha20 — no one can sniff your traffic.
Key-based Auth
No passwords — a public/private key pair keeps you secure and hands-free.
Port Forwarding
Tunnel remote ports to your local machine for access to internal services.
File Transfer
Use SCP or SFTP to securely move files between machines over SSH.
Connecting to a Server
The most basic SSH command follows this pattern:
The terminal will ask: "Are you sure you want to continue connecting (yes/no)?" — type yes. This saves the server fingerprint so future connections are verified automatically.
Password-free Login with SSH Keys
Typing a password every time is tedious and less secure. SSH keys let you log in instantly, hands-free, with stronger cryptographic protection.
Step 1 — Generate a key pair
Step 2 — Copy public key to the server
id_ed25519 (without .pub) must stay on your machine only. The .pub file is what you copy to servers.
Set Up Shortcuts with ~/.ssh/config
Instead of typing long commands every time, define named aliases in your SSH config file.
ssh prod or ssh staging — the config handles everything else automatically.
Common SSH Flags
Transfer Files with SCP
Starting from Scratch? Follow These Steps
Install an SSH client
Mac and Linux have it built in. On Windows, enable OpenSSH from Settings or install Git Bash.
Get your server credentials
From AWS, DigitalOcean, or your VPS provider — grab the IP address, username, and any key file they provide.
Connect for the first time
Run ssh username@ip, accept the fingerprint prompt, and you are in.
Set up SSH keys
Run ssh-keygen to create a key pair, then use ssh-copy-id to push the public key to your server.
Add a shortcut to ~/.ssh/config
From now on, ssh prod is all you need to type.
Once comfortable with the basics, explore SSH tunneling, jump hosts (bastion servers), agent forwarding, and tmux for persistent remote sessions.
