set up an ssh key
Make a key, put it on a server to log in without a password, use a given key, change its passphrase.
Steps
-
ssh-keygen -t ed25519make a key pair in ~/.ssh; the passphrase protects it
-
ssh-copy-id NAME@hostput the public key on the server
-
ssh -i ~/.ssh/work_key NAME@hostlog in with a given key
-
ssh-keygen -p -f ~/.ssh/id_ed25519change or remove its passphrase
-
GIT_SSH_COMMAND='ssh -i ~/.ssh/work_key' git clone [email protected]:org/repo.gituse a given key for git
-
chmod 600 ~/.ssh/id_ed25519"permissions too open": only you may read a private key
Notes
- Hosts and keys can go in ~/.ssh/config: Host work, HostName, User, IdentityFile.
- Share only the .pub file; the other one stays on your machine.
Commands used
ssh-keygenssh-copy-idssh
Each has a page in lore: lore ssh-keygen opens it.
Related recipes
- check a certificateSee a site's TLS certificate, when it expires and who issued it, or the same for a .pem file.
- change permissions of a folder and everything in itGive a folder, its subfolders and its files the permissions or the owner they need, without making them open to everyone.
- check a file's permissionsSee who may read, write and run a file or a folder, and why a path is refused.
- copy files to and from a serverCopy a file or a whole folder between this machine and another one over ssh.