SSH commands
Updated 2026-02-15
SSH, SCP, and SSH key management. Connect to servers, copy files, and manage authorized keys.
Connect and keys
ssh user@hostSSH into host as user.
ssh -i ~/.ssh/key user@hostUse specific key.
ssh-keygen -t ed25519 -C emailGenerate key pair.
ssh-copy-id user@hostCopy public key to host (Linux/macOS).
eval $(ssh-agent); ssh-add ~/.ssh/keyAdd key to agent.
SCP and SFTP
scp file user@host:pathCopy file to remote.
scp user@host:path fileCopy file from remote.
scp -r dir user@host:pathCopy directory recursively.
sftp user@hostInteractive SFTP session.
Config
~/.ssh/config: Host alias, HostName host, User user, IdentityFile ~/.ssh/key. Then: ssh alias.