How to connect with SSH

Overview

SSH provides an encrypted remote shell. You need a server hostname or IP address, a remote username, and either a password or SSH key authorized by that server.

Connect and leave

ssh [email protected]
ssh -p 2222 [email protected]
ssh -i ~/.ssh/id_ed25519 [email protected]
exit

Useful options and tools

  • -p port selects a non-default port
  • -i keyfile selects a private key
  • ssh-keygen -t ed25519 creates a modern key pair
  • ssh-copy-id user@host installs a public key when supported
  • scp file user@host:path/ copies a file over SSH

Security

On the first connection, compare the displayed host-key fingerprint with one obtained through a trusted channel. Do not accept an unexpected changed-key warning without investigation.

Protect private keys, use a passphrase, and never share the private key file. Remote commands can be just as destructive as local ones.