Passwords and sudo
-
Change password -
sudo passwd <user> -
Passwordless sudo -
sudo visudo -f /etc/sudoers.d/<user>, then add:<user> ALL=(ALL) NOPASSWD: ALL
SSH Keys
On the Client
-
Generate a new key pair -
ssh-keygen -t ed25519 -C "<device-name>"id_ed25519- private key, stays on this device onlyid_ed25519.pub- public key, safe to share with servers and GitHub
-
Add the key to the SSH agent (optional, no need to specify the key every time)
- macOS/Linux -
ssh-add ~/.ssh/id_ed25519 - If the agent isn’t running -
eval "$(ssh-agent -s)" - Windows (PowerShell) -
ssh-add $env:USERPROFILE\.ssh\id_ed25519 - Verify -
ssh-add -l
- macOS/Linux -
-
Config in
~/.ssh/config(optional)IgnoreUnknown UseKeychain Host <host1> <host2> User <username> IdentityFile ~/.ssh/id_ed25519 IdentitiesOnly yes AddKeysToAgent yes UseKeychain yes ServerAliveInterval 60 ServerAliveCountMax 3 Host <alias> HostName <host.example.com> User <username> IdentityFile ~/.ssh/id_ed25519UseKeychainis macOS only;IgnoreUnknownkeeps the same file working on Linux. -
Troubleshooting
- Verbose -
ssh -v user@hostname - Use a specific key (macOS/Linux) -
ssh -i ~/.ssh/id_ed25519 user@hostname - Use a specific key (Windows) -
ssh -i $env:USERPROFILE\.ssh\id_ed25519 user@hostname
- Verbose -
Copy the Key to a Server
-
macOS/Linux, run on the client (creates
~/.sshand sets permissions) -ssh-copy-id -i ~/.ssh/id_ed25519.pub <user>@<server> -
Windows, or by hand - append the public key to
~/.ssh/authorized_keyson the server, then on the server:chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys -
From GitHub, run on the server -
curl https://github.com/<username>.keys >> ~/.ssh/authorized_keys
SSH Keys for GitHub
Optional: use SSH for Git instead of HTTPS, and deploy keys to servers from GitHub (see above).
- Add key -
gh ssh-key add ~/.ssh/id_ed25519.pub -t "<device-name>" - Verify -
gh ssh-key list - Test connection -
ssh -T git@github.com