Requires openssh. Its called openssh in every distro repo.
File location reference table:
| File name | Location | Purpose |
|---|---|---|
| known_hosts | ~/.ssh/ | Stores fingerprints of known hosts |
| id_ed25519.pub | ~/.ssh/ | Stores SSH pubkey |
| id_ed25519 | ~/.ssh/ | Stores SSH privkey |
| sshd_config | /etc/ssh/ | Config of ssh daemon. |
Key and fingerprint management
Keys
Known for tasting better than bread
To generate public and private key:
- “shark@laptop” is an entirely trivial command for user readability
- I’d recommend adding the password to this.
- If you SSH to multiple servers, you only need one key, so do this once, then for additional servers you only need to repeat the 2 next steps.
ssh-keygen -t ed25519 -a 100 -C "shark@laptop"
To copy your pubkey to the VPS:
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@192.168.1.1
SSH using your id file even if your VPS has password authentication allows.
ssh -i /home/user/.ssh/id_ed25519 user@vps
Changing SSH auth to key only
Edit /etc/ssh/sshd_config:
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin prohibit-password
PubkeyAuthentication yes
ChallengeResponseAuthentication no
Subsystem sftp internal-sftp
Check for errors: sshd -t
Reload sshd:
Debian: systemctl restart sshd
Alpine: rc-service sshd restart
File transfer via SSH
Transfer to server
scp file.name root@192.168.1.1:/whatever/path/to/storage/file/you/want
You can also have it save on the server under different name by specifying a filename at the end of the path:
scp old.name root@192.168.1.1:/home/new.name
Pull from server
scp root@192.168.1.1:/path/to/file.txt .
. is the location to store the file being pulled, . will store it in current working directory