Skip to content

Instantly share code, notes, and snippets.

@cryptozeny
Created June 22, 2019 23:26
Show Gist options
  • Save cryptozeny/da9d49d06db0b659e5444a6055bc439f to your computer and use it in GitHub Desktop.
Save cryptozeny/da9d49d06db0b659e5444a6055bc439f to your computer and use it in GitHub Desktop.
ssh without password
targetUSER="root" && \
targetIP="149.28.43.9" && \
ssh ${targetUSER}@${targetIP} mkdir -p .ssh && \
cat ~/.ssh/id_rsa.pub | ssh ${targetUSER}@${targetIP} 'cat >> .ssh/authorized_keys'
enter password twice
@cryptozeny
Copy link
Author

cryptozeny commented Aug 17, 2019

on AWS

keyLocation="$HOME/key.pem" &&\
targetUSER="ubuntu" &&\
targetIP="ec1-23-45-678-901.ap-northeast-2.compute.amazonaws.com" &&\
ssh -i "$keyLocation" ${targetUSER}@${targetIP} mkdir -p .ssh &&\
cat ~/.ssh/id_rsa.pub | ssh -i "$keyLocation" ${targetUSER}@${targetIP} 'cat >> .ssh/authorized_keys' &&\
ssh ${targetUSER}@${targetIP}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment