Last active
February 4, 2016 23:18
-
-
Save pavel-arapov/8fd33c87db51cab04494 to your computer and use it in GitHub Desktop.
Upload public ssh key to remote server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| echo usage: $0 user@server | |
| exit | |
| fi | |
| echo "uploading key to $1"; | |
| cat ~/.ssh/id_rsa.pub | ssh $1 'cat > key.pub && [ -d .ssh ] || mkdir .ssh && [ -d .ssh/autorized_keys2 ] || touch .ssh/autorized_keys2 && cat key.pub >> ~/.ssh/authorized_keys2 && rm key.pub' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment