SSH - SecureShell

SSH - SecureShell

  • TCP/IP port 22
  • sshd - ssh server
    • package openssh-server
    • default sshd server config /etc/ssh/sshd_config
  • ssh - ssh client
    • package openssh-client
    • default ssh client config /etc/ssh/ssh_config or ~/ssh/config
# Usage:
# -v = verbose mode for debugging
# -4 = forces IPv4
# -6 = forces IPv6
# -i = specify the identity private keys
# -p = port

ssh user@HOST
ssh -i private_key_file user@HOST
ssh HOST # if the ssh keys are already copied in the server
  • Generating the SSH keys - ssh-keygen
# Usage:
# -t = type of key, dsa, ecdsa, ecdsa-sk, ed25519, ed25519-sk, rsa, rsa-sha2-512(DEFAULT)
# -b = Key length
# -f = Specify file to write to
# -C = comment
ssh-keygen -t rsa -b 4096
ssh-keygen -t ed25519
  • Securely copying public SSH keys - ssh-copy-id
# Usage:
# -i = Specify the ssh keys file
# -p = Port to login
ssh-copy-id -i ~/.ssh/id_rsa.pub user@HOST
  • scp & sftp

OS and packages

apt install openssh-server openssh-client  # debian/ubuntu
yum install openssh # centos/fedora(dnf, microdnf, rpm, yum)
pacman -S openssh # arch(pacman)
apk add openssh # alpine
brew install openssh  # OS X