Skip to content

Instantly share code, notes, and snippets.

@soreana
Created March 24, 2019 10:16
Show Gist options
  • Save soreana/80d32d4193d9e5d3f31185e46a940f03 to your computer and use it in GitHub Desktop.
Save soreana/80d32d4193d9e5d3f31185e46a940f03 to your computer and use it in GitHub Desktop.
automate ssh login using RSA
# Put your id_rsa.pub and autologin file at the same folder. Run `chmode +x autologin.sh` then `./autologin` to automate
# your login.
#!/bin/bash
mkdir -p ~/.ssh && \
chmod 700 ~/.ssh && \
touch ~/.ssh/authorized_keys2 && \
chmod 600 ~/.ssh/authorized_keys2 && \
cat ./id_rsa.pub >> ~/.ssh/authorized_keys2
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiVg7xjAH8GikwLsFB+v9PjkP2ByTBQZVsxfuxbVivHjrvcvKHIhtOVE0NJ5ESOuwSggSPYYSMbIls9jaP4vXjUolggbmM0BnFJ182sb+2GuJ7TewtQG8BHitK+BgNaKHFAkZ/aolBHwl53RGOSvQpg8fOGjZoLVGnvTqUJjdqzWxwoL13DYXz8seo0YWvkTAFUf2P9sAOXAJOmUe+ADOv5r3ly7sd7if1tBQGfmYIPO9jDxauX3GE4mpEFTx+yYgt3CPXSQh8sYjbnTvOWaNRWJ/CxoXRyXo3D5i2qBqsNKeFMoknBiEZP/QFLC9lXni3p8L7CoRBZxeizTHGpKaB sinakashipazha@Deunans-MacBook.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment