SSH, packages and services
Key-based login without passwords, copying files safely, installing software, and managing services.
Connecting
ssh ada@server.example
ssh -p 2222 ada@server.example
ssh -i ~/.ssh/id_ed25519 ada@server
# keys beat passwords: immune to brute force, better automation
ssh-keygen -t ed25519 -C 'ada@example'
ssh-copy-id ada@server| File | Contents |
|---|---|
~/.ssh/id_ed25519 | Private key — never leaves your machine |
~/.ssh/id_ed25519.pub | Public key — safe to distribute |
~/.ssh/known_hosts | Fingerprints of hosts you have seen |
~/.ssh/config | Per-host shortcuts |
# ~/.ssh/config - then just: ssh web
Host web
HostName 203.0.113.10
User ada
Port 2222
IdentityFile ~/.ssh/id_ed25519⚠️
A private key with loose permissions is refused by SSH:
chmod 600 ~/.ssh/id_ed25519. And never copy a private key onto a shared server — use agent forwarding or generate keys where they are used.Copying files
scp file.txt ada@web:/var/www/
scp -r ./dist ada@web:/var/www/app/
scp ada@web:/var/log/app.log ./ # download
# rsync: only transfers differences, resumable
rsync -avz --progress ./dist/ ada@web:/var/www/app/
rsync -avz --exclude 'node_modules/' ./ ada@web:/srv/app/Installing software
| Family | Install |
|---|---|
| Debian / Ubuntu | apt update && apt install nginx |
| RHEL / Fedora | dnf install nginx |
| Alpine | apk add nginx |
| macOS (Homebrew) | brew install node |
apt search nginx
apt show nginx
sudo apt update && sudo apt upgrade -y
sudo apt autoremove # remove orphaned dependenciesManaging services
sudo systemctl status nginx
sudo systemctl restart nginx
sudo systemctl enable nginx # start on boot
journalctl -u nginx -f # live logs
journalctl -u nginx --since '10 min ago'💡
start begins now, enable configures boot. Most people want both: systemctl enable --now nginx.FAQ
SSH asks for a password despite my key?
Check remote
~/.ssh permissions (700) and authorized_keys (600), confirm the public key was appended, and verify the server allows key auth.WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED — what now?
Usually a legitimate server rebuild. If you did not expect it, investigate before connecting. Remove the stale line with
ssh-keygen -R <host>.Related
Hash functions: MD5, SHA-1, SHA-256 Shell basics and navigation
Last refreshed 2026-09-17.