Skip to content

Instantly share code, notes, and snippets.

@greenkey
Forked from anonymous/ssh-regsrv.sh
Last active February 25, 2016 12:46
Show Gist options
  • Save greenkey/a6d87081a55efa8b8b1e to your computer and use it in GitHub Desktop.
Save greenkey/a6d87081a55efa8b8b1e to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ ! -f ~/.ssh/id_rsa.pub ]; then
ssh-keygen
fi
echo "Server host:"
read SRV
echo "User on the server host:"
read USR
ssh $USR@$SRV 'mkdir .ssh; chmod 700 .ssh; touch .ssh/authorized_keys2; chmod 640 .ssh/authorized_keys2'
cat ~/.ssh/id_rsa.pub |ssh $USR@$SRV 'cat >> .ssh/authorized_keys2'
@greenkey
Copy link
Author

AFAIK This does the same thing as the command ssh-copy-id

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