Created
September 2, 2014 22:11
-
-
Save yevrah/45e4f102169b4c4fcb4f to your computer and use it in GitHub Desktop.
Copy SSH Keys To Remote Server
This file contains 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
#!/usr/bin/env bash | |
# Usage | |
# copy_ssh_keys.sh user@host | |
# | |
# Notes | |
# Makes sure to generate your ssh keys before running, if | |
# you havent done so just uncomment the line below | |
# ssh-keygen -t rsa | |
echo -e "\n>>> Creating remote .ssh folder" | |
ssh -t $1 "mkdir ~/.ssh" | |
echo -e "\n>>>Updating .ssh folder permissions" | |
ssh -t $1 "chmod 700 ~/.ssh" | |
echo -e "\n>>>Copying Auth Keys" | |
cat ~/.ssh/id_rsa.pub | ssh $1 "cat >> ~/.ssh/authorized_keys" | |
echo -e "\n>>>Updating auth keys permissions" | |
ssh -t $1 "chmod 600 ~/.ssh/authorized_keys" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment