ssh
Make a key pair with ssh-keygen, install it with ssh-copy-id, then log in to the server with ssh — no password.
>_ Try it: a simulated Linux, right herenothing runs on your computer
Loading the terminal…
Examples
-
ssh-keygen -t ed25519 -
ssh-copy-id deploy@web-01 -
ssh deploy@web-01 hostname -
ssh deploy@web-01 -
whoami -
exit
How it works
ssh USER@HOST opens a shell on another machine: every command you type runs there, until exit brings you back.
Keys beat passwords: ssh-keygen makes a pair, a private key that never leaves your computer and a public key (.pub). ssh-copy-id puts the public one in the server's ~/.ssh/authorized_keys, and from then on the key logs you in.
Syntax
ssh [-i KEY] [-p PORT] USER@HOST [COMMAND]
Options
| Option | What it does |
|---|---|
USER@HOST | who to log in as, and where |
COMMAND | run one command there and come straight back |
-i FILE | use this private key |
-p PORT | another port than 22 |
ssh-keygen | make a key pair (-t ed25519) |
ssh-copy-id | install your public key on a server |
Good to know
- The private key must be readable by you only: ssh refuses it with "UNPROTECTED PRIVATE KEY FILE" otherwise (
chmod 600). - The first time, ssh asks you to trust the server's fingerprint and remembers it in
~/.ssh/known_hosts.