→ From Coder to Shipper
From Coder to Shipper · Infrastructure

SSH — your secure remote hand on a VPS

Your VPS is a remote machine. SSH is the encrypted way to log into it, run commands, move files and reach things only it can see — replacing insecure telnet.

← / → to navigate · EN/VI switch below · the architect's view — mental model first, a few small examples

The problem

A VPS is a remote machine — you need a safe remote hand

You can't plug a keyboard into it. Everything you do to it happens over the network — so how you log in decides how safe it is.

Telnet sends everything in the open

telnet is the old way in. It sends your username AND password in plaintext — readable by anyone on the wire between you and the VPS.

The wire is not yours

Your traffic crosses routers, ISPs and cables you don't control. On any hop, a sniffer sees your login — including the password — in cleartext.

You need a remote hand

To ship, you'll log in, run commands, edit files and reach services that only the VPS can see. That remote hand must be safe, not just convenient.

SSH is the answer

SSH = Secure Shell. It does the same job as telnet — remote login plus a shell — but encrypts the whole conversation so the wire only ever carries gibberish.

The picture

The open wire vs the tunnel

The same login — one readable by anyone, one unreadable by anyone.

telnet · port 23
Your laptopyou, logging in
→username + password in cleartext
VPS :23 every packet on the wire is readable
ssh · port 22
Your laptopyou, logging in
→the whole session, encrypted
VPS :22 the wire only carries ciphertext

Telnet hands your credentials to the wire. SSH wraps the entire session in a tunnel — from the password to the very last command you type, nobody on the wire can read it.

The core

SSH in one breath

It's encrypted

From the moment you connect, your username, password and every command are unreadable to anyone on the wire. The tunnel is the whole point.

Remote login + shell

ssh user@host drops you into a real shell on the VPS. Type a command, it runs there, you see the output — as if you were sitting at that machine.

File transfer

scp and sftp copy files to and from the VPS over the same encrypted channel — the same security, for moving files instead of typing commands.

Tunnels

Port forwarding lets you reach things that only the VPS can see — a database on its private network — through the encrypted pipe.

Telnet is a conversation shouted across an open field. SSH is the same conversation in a sealed, encrypted tube — the field can't read it.
— the whole difference, in one image
01
Part 1

Connecting — ssh user@host

The first command, the custom port, and the fingerprint prompt you'll see exactly once per server.

The first time

Logging in — and the fingerprint prompt

Default port is 22; -p overrides it. The first connect asks you to confirm a fingerprint — a one-time 'trust this server' decision.

ops@vps — zsh
# default port is 22 — -p 2222 uses a custom one
$ ssh deploy@203.0.113.10
The authenticity of host '203.0.113.10 (203.0.113.10)' can't be established.
ED25519 key fingerprint is SHA256:AbCdEf1234567890GhIjKlMnOpQr.
Are you sure you want to continue connecting (yes/no)? yes
# now you're in a shell on the VPS — commands run there
$ pwd
/home/deploy
Under the hood

The fingerprint — trust-on-first-use

The server shows its key

Every SSH server has a host key. On first connect it shows a fingerprint (a short hash of that key) so you can verify you're talking to the right server — not an impostor.

You verify it once

You check the fingerprint against the value the provider gave you (console, email). Match? Type yes. That's the whole trust step.

Trust-on-first-use

Once accepted, the fingerprint is remembered on your machine. Future connects are silent — and if the server's key ever CHANGES, SSH warns you loudly (possible MITM).

02
Part 2

Keys beat passwords

Passwords are guessable and phishable. A key pair is unforgeable math. Here's how to set it up — and how to lock the door behind it.

Two ways in

Password auth vs key auth

Password

You type a secret both sides know. It can be guessed, leaked, phished or reused. Every login sends it across the wire — encrypted, but still a moving secret.

Key pair

You generate a private key (your secret) and a public key (your name). The server stores only the public key. Login proves you hold the private key — no secret ever travels.

The flow

Key-based login, in three moves

  1. 1

    Generate the pair

    ssh-keygen creates a private key (keep it — never share) and a matching public key. Accept the defaults or add a passphrase.

  2. 2

    Copy the public key

    ssh-copy-id sends your PUBLIC key to the server and appends it to ~/.ssh/authorized_keys. Only the public half ever travels.

  3. 3

    Log in passwordless

    Now ssh asks for no password — it proves you with your private key. Same security, zero typing, and nothing to phish.

The commands

Generate and install the key

Two commands on your laptop do the whole job. The private key stays here; only the public key reaches the VPS.

ops@vps — zsh
# 1) generate a key pair on your laptop
$ ssh-keygen -t ed25519
Generating public/private ed25519 key pair.
Your identification has been saved in /home/you/.ssh/id_ed25519.
Your public key has been saved in /home/you/.ssh/id_ed25519.pub.
# 2) copy the public key to the VPS
$ ssh-copy-id deploy@203.0.113.10
Number of key(s) added: 1.
Lock the door

Now turn off password login

Once keys work, remove the password route so only keys get in. One line, and the password becomes irrelevant.

One line on the server

In /etc/ssh/sshd_config, set PasswordAuthentication no. Restart the SSH service. From then on, only key-based logins are accepted.

Keep a way in

Make sure your key login works BEFORE you disable passwords — and keep a provider console open as a failsafe. Lock yourself out and you're stuck.

Why it matters

No password = nothing to brute-force, phish or stuff. An attacker who finds your server still can't get in without the private key.

03
Part 3

Moving files — scp, sftp, rsync

The same encrypted channel, now for files. One to copy, one to browse, one to sync.

The three tools

One to copy, one to browse, one to sync

scp — copy

cp for the network. scp file user@host:/path copies a file to (or from) the VPS over the encrypted channel. One command, done.

sftp — browse

An interactive file shell. sftp user@host drops you in a little prompt where you ls, cd, get, put — a safer cousin of ftp.

rsync — sync

The workhorse for bigger jobs. rsync diffs the two sides and transfers only what changed — resumable, fast, and it can run over ssh.

Tiny examples

Copy one file, or open a file shell

bash
# scp: copy a file TO the VPS
scp deploy.py deploy@203.0.113.10:/home/deploy/

# scp: copy a file FROM the VPS
scp deploy@203.0.113.10:/var/log/app.log ./app.log

# sftp: interactive file shell
sftp deploy@203.0.113.10
sftp> ls
sftp> get app.log
sftp> bye

# rsync: sync a folder over ssh
rsync -avz --progress ./site/ deploy@203.0.113.10:/var/www/site/

scp is one-shot (to/from), sftp is the interactive browse-and-get/put shell, and rsync is the resumable diff-based sync — all over the same encrypted channel.

04
Part 4

Tunnels — a pipe through the pipe

The mental model: a tunnel runs THROUGH your encrypted SSH connection to reach things only the VPS can see.

The picture

A tunnel through the encrypted connection

Local forward (-L): your laptop → encrypted SSH → VPS → private network → the database.

local
Your laptopyou connect to 127.0.0.1:5432
→ssh -L 5432:10.0.0.5:5432
(encrypted)
VPS — the relaycarries the tunnel
→private network
Database 10.0.0.5:5432 — private only

You point your DB client at 127.0.0.1:5432 (localhost). SSH carries that traffic, encrypted, through to the private database on the VPS's internal network — which the internet can't reach at all. No public port, no exposure.

The flags

-L in depth — and -R, -D in a line

-L: local forward (the one you'll use)

ssh -L 5432:10.0.0.5:5432 user@vps opens port 5432 on YOUR laptop; anything sent to it is tunnelled, encrypted, to 10.0.0.5:5432 as seen from the VPS. Reach a private DB without ever exposing it.

-R: remote forward

The mirror image — opens a port on the VPS that tunnels back to something on your machine. Useful when the other side can't reach you directly.

-D: dynamic (SOCKS) proxy

Opens a local SOCKS proxy; any app pointed at it routes all its traffic through the VPS. The general-purpose version of the same idea.

05
Part 5

Your daily driver — ~/.ssh/config

The quality-of-life win: name your servers once, then ssh myvps and go. No typing hostnames, ports or key paths every single time.

The file

~/.ssh/config — a Host block

~/.ssh/config
# ~/.ssh/config — one block per server
Host myvps
    HostName 203.0.113.10
    User deploy
    Port 22
    IdentityFile ~/.ssh/id_ed25519

# now this just works:
ssh myvps

Define a Host alias once with HostName, User, Port and IdentityFile — after that, ssh myvps, scp file myvps:/path and ssh -L ... myvps all use it automatically.

The win

Why this is the daily-driver win

Name, don't type

ssh myvps instead of ssh -i ~/.ssh/id_ed25519 deploy@203.0.113.10. Short, memorable, hard to typo. Every tool that takes a host (ssh, scp, sftp) honors the alias.

One source of truth

Change a port or key path once in the file and every command updates. New server? Add one Host block. It scales from one VPS to ten without muscle memory failing.

Works with everything

The alias carries User, Port and IdentityFile — so tunnels (ssh -L ... myvps), copies (scp x myvps:/path) and everything else inherit the config for free.

06
Part 6

The big picture

Zoom out. SSH is not a pile of flags — it's one secure relationship with your VPS.

Zoom out

One secure remote hand, two skills that matter

SSH = your secure remote hand

Login, run commands, move files, reach private things — all encrypted, all from your laptop. It's the single channel you manage the VPS with.

The two skills that matter most

Key-based login (so there's nothing to phish or guess) and tunnels (so private things stay private). Master those two and the rest of SSH is convenience on top.

SSH is the handshake between you and your VPS — encrypted from the first byte to the last. Get keys and tunnels right and the rest writes itself.
— the whole deck, in one line

Now go ship — with a secure remote hand

ssh user@host, keys over passwords, one tunnel to the private stuff — and a ~/.ssh/config alias so you never type it all again.