SSH: Basics


Secure Shell: secure login to remote computers

  • Unencrypted protocols, like rsh, rlogin, telnet, …

  • ⟶ passwords readable on the wire

  • ⟶ NSA must have it a bit harder!

  • ⟶ SSH


  • SSH is a protocol (primarily, at least))

  • Main task: authentication and encryption

  • Main usage: remote login

  • Further usages

    • Copy data over the wire (scp)

    • File transfer (sftp). Also usable as a network file system (⟶ sshfs/FUSE)

    • Port forwarding

    • Tunneling (a.k.a VPN)


Logging in as user jfasch

$ ssh

Logging in under the same username as local

$ ssh

Logging in and executing a remote command (using one’s login shell)

$ ssh ls -l
$ ssh 'ps -efl | grep sshd'    # quoting necessary: '|' is a shell metacharacter

Exit Status, stdin, stdout: Scripting

Exit status of the remote command is propagated

$ ssh rm -f /etc/passwd
rm: unable to remove `/etc/passwd': Permission denied
$ echo $?

Standard Input, Output (und Error) are propageted, too

$ { echo hallo; echo hello; } | \
  ssh cat | \
  wc -l


  • Only the middle part of the pipeline (ssh cat) runs on the remote computer

  • wc -l runs locally