Upgrade to Pro — share decks privately, control downloads, hide ads and more …

10 advanced, yet digestible SSH techniques

10 advanced, yet digestible SSH techniques

In today's world of Github, Bitbucket, AWS/EC2, and Virtualization in General, it is helpful to understand public key authentication and SSH in general. The good news is that this seemingly cryptic and magical technology is quite easy to get a handle on once you know a few snazzy recipes.

BONUS: There are two easter eggs "hidden" plainly in the slides. Both are language constructs (one ruby-ism and one regex-ism). Where are they and what do they do?

Wil Moore III

March 01, 2013
Tweet

More Decks by Wil Moore III

Other Decks in Technology

Transcript

  1. Share Public Key Only Never share your "Private Key" Do

    share "Public Key" with trusted hosts Remote login: Provide your passphrase
  2. Hostname Completion Type a few characters...press tab https://github.com/wilmoore/ruby-version/blob/master/ruby-version.sh#L67 Completion is

    easy...see: https://github.com/wilmoore/php-version/blob/master/php-version.sh#L73 List filtered based on prefix
  3. Remote Filename Completion Type a path prefix...<tab> The kestrel directory

    is expanded...<tab> Directory contents are expanded
  4. SSH + HEREDOC % ssh -t … <<ssh-session # body

    of your script goes here # more body # ... ssh-session
  5. Hey Netflix, your country check is annoying; however, I didn’t

    watch anything so please don’t terminate my account.
  6. Y-U-NO NETFLIX IN CANADA? OH come on now Netflix!! Create

    the SOCKS proxy SOME-HOST-NOT-TELLING
  7. Github SSH Key Generation Help https://help.github.com/articles/generating-ssh-keys Recover SSH key passphrase

    https://help.github.com/articles/how-do-i-recover- my-ssh-key-passphrase Resources
  8. Restrict what clients can do ssh-rsa bbbbB3NzaC1yc2EAAEy0TOB0MTYhzKSaD//szJ9FFR0pY+G0M2pi/ Wcbcj55KtYzBpYPNz8uV3T2N24PU9jybUD+n5ge/nTBRVgGu6Rk/ 7Fu9jdhmwOfxGlfFme/ no-port-forwarding,no-pty

    ssh-rsa bbbbB3NzaC1yc2EAAEy0TOB0MTYhzKSaD/ szJ9FFR0pY+G0M2pi/Wcbcj55KtYzBpYPNz8uV3T2N247Fu9jdhmwOfxGlfFme/ COMMAND=”printf 'Unable to run %s\n' ${SSH_ORIGINAL_COMMAND}” ssh- rsa bbbbB3NzaC1yc2EAAEy0TOB0MTYhzKSaD/szJ9FFR0pY+G0M2pi/ git clone [email protected]:wilmoore/frontend-packagers.git
  9. /etc/fail2ban/jail.local [ssh] enabled = true port = ssh filter =

    sshd logpath = /var/log/auth.log maxretry = 6 [ssh-ddos] enabled = true port = ssh filter = sshd-ddos logpath = /var/log/auth.log maxretry = 6