Generate an ed25519 key pair; shorter and faster than RSA
ssh-keygen -t ed25519 -C "you@example.com"Key-based SSH login, ssh config host aliases, local and remote port forwarding, plus scp and rsync incremental sync recipes with dry-run previews and permission fixes.
Generate an ed25519 key pair; shorter and faster than RSA
ssh-keygen -t ed25519 -C "you@example.com"Append the public key to the remote authorized_keys for passwordless login
ssh-copy-id -i ~/.ssh/id_ed25519.pub deploy@10.0.0.12Start the agent, load the key once and list loaded keys with -l
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add -lPut this in ~/.ssh/config to run ssh prod; keepalive reduces idle disconnects
Host prod
HostName 10.0.0.12
User deploy
Port 2222
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 30Keep the config at 600 or newer OpenSSH versions ignore the key.
Log in on a custom port; note that scp uses uppercase -P
ssh -p 2222 deploy@10.0.0.12Reach an internal host through a bastion without a separate login
ssh -J jump@bastion.example.com deploy@10.0.0.12Local forward: map local 3307 to remote MySQL; -N skips the shell, -f backgrounds it
ssh -N -f -L 3307:127.0.0.1:3306 deploy@10.0.0.12Remote forward: expose local 3000 on the remote 9000 for callbacks and demos
ssh -N -R 9000:127.0.0.1:3000 deploy@10.0.0.12Dynamic forward creates a SOCKS5 proxy on 127.0.0.1:1080
ssh -N -D 1080 deploy@10.0.0.12Recursively copy over SSH; always full transfer, fine for small outputs
scp -P 2222 -r ./dist deploy@10.0.0.12:/opt/appIncremental sync of directory contents; the trailing slash copies contents
rsync -avz --progress ./dist/ deploy@10.0.0.12:/opt/app/Dry-run first to see which extra remote files would be deleted
rsync -avz --dry-run --delete ./dist/ deploy@10.0.0.12:/opt/app/Sync and delete extra remote files; a wrong path can wipe the target
rsync -avz --delete ./dist/ deploy@10.0.0.12:/opt/app/Exclude dependency folders and logs to cut transfer volume
rsync -avz --exclude "node_modules" --exclude "*.log" ./app/ deploy@10.0.0.12:/opt/app/Use -e to pass a custom SSH port to the remote shell
rsync -avz -e "ssh -p 2222" ./dist/ deploy@10.0.0.12:/opt/app/Verbose handshake output helps locate key or algorithm negotiation issues
ssh -v deploy@10.0.0.12Authenticate without a shell to confirm a deploy key works
ssh -T git@github.comValidate sshd_config syntax before reloading to avoid locking yourself out
sudo sshd -tFix overly open permissions, the most common cause of key login failures
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys ~/.ssh/config
chmod 644 ~/.ssh/*.pubThis website uses cookies to ensure you get the best experience on our website. Privacy Policy.