Skip to content

Instantly share code, notes, and snippets.

@lizneu
Last active July 27, 2017 00:08
Show Gist options
  • Save lizneu/cf282363336f5c093a19f1c114ad1537 to your computer and use it in GitHub Desktop.
Save lizneu/cf282363336f5c093a19f1c114ad1537 to your computer and use it in GitHub Desktop.
mkdir ~/.ssh
cd ~/.ssh
PASSWORD=$(openssl rand -base64 30)
if [ "${#PASSWORD}" -ge 20 ]; then
ssh-keygen -b 4096 -P "$PASSWORD" -f id_rsa -o
echo "echo $PASSWORD" > /tmp/askpass.sh
chmod +x /tmp/askpass.sh
export DISPLAY=":0"
export SSH_ASKPASS="/tmp/askpass.sh"
ssh-add -K $HOME/.ssh/id_rsa </dev/null
rm /tmp/askpass.sh
else
echo "Something is wrong with the password."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment