Linux SSH and SCP

Key logins, tunnels, and file copies without passwords.

  • ssh key
  • ssh tunnel
  • scp
  • rsync
  • ssh-copy-id

Linux SSH and SCP

Key logins, tunnels, and file copies without passwords.

Commands

CommandWhat it does
ssh user at hostLogin with keys
ssh -i keyfile user at hostPick an identity file
ssh -L local forwardForward remote Postgres locally
scp file to hostCopy a file up
rsync avz syncFaster repeat syncs

Example

ssh-keygen -t ed25519 -C 'laptop'
ssh-copy-id user@host

FAQ

Permission denied (publickey)?

The server ignores keys when ssh dirs are group-writable - fix modes to 700 and 600.

scp vs rsync?

rsync resumes and skips unchanged files; scp always recopies - rsync wins for deploys.

常见问题

Permission denied (publickey)?
The server ignores keys when ssh dirs are group-writable - fix modes to 700 and 600.
scp vs rsync?
rsync resumes and skips unchanged files; scp always recopies - rsync wins for deploys.

Linux