Last active
May 4, 2019 20:23
-
-
Save TravisMullen/6932e19ea35f79113c51443ef079b328 to your computer and use it in GitHub Desktop.
Add SSH key to remote node.
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/sh | |
echo "What is your node's username?" | |
read REMOTE_USER_NAME | |
echo "What is your node's IP address (or hostname)?" | |
read IP_ADDRESS | |
ssh "$REMOTE_USER_NAME@$IP_ADDRESS" 'mkdir -p ~/.ssh && chmod 700 ~/.ssh && touch .ssh/authorized_keys' | |
echo "===================================================================" | |
echo " node :: ssh key directory created for user \"$REMOTE_USER_NAME\": " | |
echo " with 700 file permissions. " | |
# echo "$(ssh "$REMOTE_USER_NAME@$IP_ADDRESS" 'ls -la .ssh')" | |
echo "===================================================================" | |
cat $HOME/.ssh/id_ecdsa.pub | ssh "$REMOTE_USER_NAME@$IP_ADDRESS" 'cat >> .ssh/authorized_keys | chmod 600 .ssh/authorized_keys' | |
echo "===================================================================" | |
echo " node :: ssh keys added to \"$REMOTE_USER_NAME@$IP_ADDRESS\" .ssh/authorized_keys" | |
echo " with 600 file permissions. " | |
# echo "$(ssh "$REMOTE_USER_NAME@$IP_ADDRESS" 'ls -la .ssh/authorized_keys')" | |
echo "===================================================================" | |
echo " logout (exit) and " | |
echo " SSH back in (without a password) to confirm your key is being read." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment