Dead NorthStart a project

How-tos

How to connect to your web server with SSH

Generate a key, make your first connection, move files both directions, and get around the command line without fear of breaking anything.

  • Tools
  • 30 min to do
  • 7 steps
  • beginner

SSH is how you talk to your server directly — no control panel, no waiting for a page to load, just you and the machine. It sounds intimidating and it isn’t: reading around a server is safe, and everything in this lesson is read-only or reversible. You’ll need a terminal (built into macOS and Linux; on Windows, use the built-in Terminal or WSL) and a hosting account.

Find your SSH credentials in the hosting panel

Every decent host publishes three things somewhere in its panel, usually under a heading like “SSH Access” or “SFTP/SSH”: a hostname (something like ssh.example-host.com), a username, and a port (usually 22). Copy all three into a note. If your panel only offers FTP, email support and ask for SSH — a host that won’t give it to you is telling you something.

Generate an SSH key pair

A key pair beats a password: nothing to type, nothing to phish. Run this on your own computer, not the server:

ssh-keygen -t ed25519 -C "you@example.com"

Accept the default file location, and when it asks for a passphrase, give it one — that passphrase encrypts the key on your disk, so a stolen laptop doesn’t mean a stolen server. You now have two files: id_ed25519 (private — never leaves your machine, never gets pasted anywhere) and id_ed25519.pub (public — made to be handed out).

Add your public key to the server

If your host’s panel has an “SSH Keys” box, paste in the contents of ~/.ssh/id_ed25519.pub. If you have password SSH access already, this one command does the whole job:

ssh-copy-id -i ~/.ssh/id_ed25519.pub USERNAME@HOSTNAME

Make the first connection

ssh USERNAME@HOSTNAME

(Add -p 2222 or whatever your panel said if the port isn’t 22.) The first time, SSH asks whether to trust the server’s fingerprint — that’s normal, answer yes. You’ll land at a prompt on the server. That’s it. You’re in.

Learn the six commands that cover most visits

The command line is like a north woods trail: identical in every direction until you learn a few landmarks. These six are the landmarks.

pwd            # where am I?
ls -la         # what's here?
cd foldername  # go there (cd .. goes back up)
less file.txt  # read a file (q to quit)
cp a.txt b.txt # copy a file
tail -f log.txt  # watch a file grow, Ctrl-C to stop

None of these change anything except cp, and cp only makes copies. Wander freely.

Move a file both directions with scp

scp is cp that crosses the water. From your computer:

# your machine -> the server
scp ./local-file.txt USERNAME@HOSTNAME:~/

# the server -> your machine
scp USERNAME@HOSTNAME:~/remote-file.txt ./

The pattern is always scp SOURCE DESTINATION, and the remote side is the one with the colon. This is also how you fetch a database dump when you take a backup that actually restores.

Save the connection in your SSH config

Typing the hostname forever gets old. Put it in ~/.ssh/config (create the file if it doesn’t exist):

Host mysite
  HostName HOSTNAME
  User USERNAME
  Port 22
  IdentityFile ~/.ssh/id_ed25519

Verify the whole lesson at once: type ssh mysite, and you should land on the server with no password prompt and no flags — just the passphrase manager doing its quiet work. When two words get you onto your server, you’re done here, and half the other lessons in Shop Class just got easier.