Last Updated: April 05, 2019
·
879
· sadfuzzy

Useful ssh config

Contents of useful ~/.ssh/config:

# Set this to share connection between terminals
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
# Time to hold connection
ControlPersist 6h
Host www* mail db
  # Hostname to ssh in
  HostName %h.example.com
  # Username to login with
  User developer
  Port 22111
  RemoteForward 8080 127.0.0.1:8080

Login without password input:

  • Generate ssh-keys:

    $ ssh-keygen
  • Copy your ~/.ssh/idrsa.pub -> ~/.ssh/authorizedkeys:

    $ ssh-copy-id developer@example.com

Or

$ < ~/.ssh/id_rsa.pub ssh mail 'mkdir -p .ssh; cat >> .ssh/authorized_keys; chmod go-w .ssh .ssh/authorized_keys'
  • Now you can:

    $ ssh www1
    $ ssh db

Original