Skip to content

Instantly share code, notes, and snippets.

@pinge
Last active August 29, 2015 13:55
Show Gist options
  • Save pinge/8772625 to your computer and use it in GitHub Desktop.
Save pinge/8772625 to your computer and use it in GitHub Desktop.
SSH

SSH Agent in bash script

eval $(ssh-agent)
ssh-add
vagrant up

SSH Agent in bash command with exit code

ssh-agent bash -c 'ssh-add; command --options argument'

SSH without host key check

ssh -oStrictHostKeyChecking=no ec2-user@$ec2_ip

SSH sudo multiline command

ssh ec2-user@$ec2_ip 'sudo -u root -i <<EOF
cd /home/ec2-user
JAVA_OPTS="-Xmx2048m -Xms2048m" JAVA_HOME=$(readlink -f $(which javac) | sed "s:bin/javac::") grails --plain-output clean --non-interactive
JAVA_OPTS="-Xmx2048m -Xms2048m" JAVA_HOME=$(readlink -f $(which javac) | sed "s:bin/javac::") grails --plain-output refresh-dependencies --non-interactive
JAVA_OPTS="-Xmx2048m -Xms2048m" JAVA_HOME=$(readlink -f $(which javac) | sed "s:bin/javac::") grails test-app --stacktrace --non-interactive
JAVA_OPTS="-Xmx2048m -Xms2048m" JAVA_HOME=$(readlink -f $(which javac) | sed "s:bin/javac::") grails --plain-output prod war ./build/build.war --non-interactive
EOF
'

PEM private key to RSA private key

e.g. debug1: read PEM private key done: type <unknown>

openssl rsa -in ~/.ssh/privatekey.pem -out ~/.ssh/privatekey_rsa
chmod 600 ~/.ssh/privatekey_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment