ssh opens a shell on another machine over an encrypted connection. It is how nearly all server work happens, and its config file quietly turns twenty-character commands into two-letter ones.
Connect #
$ ssh ana@203.0.113.7
$ ssh -p 2222 ana@build.aospix.com
The first connection asks you to trust the host key — say yes from a machine you control — then authenticates you. Passwords work, but keys are better: ssh-keygen creates a pair once, and ssh-copy-id ana@host installs your public key so logins after that need no password at all.
Run one command and leave #
Everything after the host executes remotely, and the connection closes when it finishes:
$ ssh ana@build.aospix.com "df -h /"
That form is half of every automation script; the other half is curl when the remote thing speaks HTTP.
The config file #
A ~/.ssh/config entry turns hosts into names:
Host build
HostName build.aospix.com
User ana
Port 2222
IdentityFile ~/.ssh/id_ed25519
After that, ssh build carries all four settings — and scp and git remotes inherit the same shortcut.
The flags worth knowing #
| Flag | Meaning |
|---|---|
-p port | Connect to a non-default port |
-i file | Use a specific identity (key) file |
-v | Verbose — the debugging lifeline when login fails |
-L 8080:localhost:80 | Forward a local port to the remote side |
Once logged in, everything in this series applies remotely: systemctl for services, ps and top for load, df for disks. More in the journal.
