Skip to content

Instantly share code, notes, and snippets.

@dbonates
Last active December 16, 2015 13:28
Show Gist options
  • Save dbonates/5441367 to your computer and use it in GitHub Desktop.
Save dbonates/5441367 to your computer and use it in GitHub Desktop.
public keys for access without login prompt
#TODO: Adicionar o arquivo com o script local, que deve ser executado antes deste.
echo "remote ip:"
read TARGETIP
# generating keys
ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
# sending to remote server (as root)
scp ~/.ssh/id_rsa.pub root@$TARGETIP:
# on remote server:
echo "Type the username which will login with this key:"
read USERNAME
mkdir .ssh
mv id_rsa.pub .ssh/authorized_keys
chown -R $USERNAME:$USERNAME .ssh
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment