Skip to main content
Ganesh Joshi
Back to Cheatsheets

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@host

    SSH into host as user.

  • ssh -i ~/.ssh/key user@host

    Use specific key.

  • ssh-keygen -t ed25519 -C email

    Generate key pair.

  • ssh-copy-id user@host

    Copy public key to host (Linux/macOS).

  • eval $(ssh-agent); ssh-add ~/.ssh/key

    Add key to agent.

SCP and SFTP

  • scp file user@host:path

    Copy file to remote.

  • scp user@host:path file

    Copy file from remote.

  • scp -r dir user@host:path

    Copy directory recursively.

  • sftp user@host

    Interactive SFTP session.

Config

~/.ssh/config: Host alias, HostName host, User user, IdentityFile ~/.ssh/key. Then: ssh alias.

SSH commands | Cheatsheet | Ganesh Joshi