AlexanderNorup

AddKeyToSSH.sh

May 1st, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.36 KB | None | 0 0
  1. #!/bin/bash
  2. echo "Connect to an SSH server in order to add your public key to the servers ~/.ssh/authorized_keys"
  3.  
  4. echo "[SSH] Connect to: "
  5. read serverIP
  6. echo "[SSH] Login as: "
  7. read serverUser
  8. echo Pushing ~/.ssh/id_rsa.pub to $serverUser@$serverIP ~/.ssh/authorized_keys
  9.  
  10. cat ~/.ssh/id_rsa.pub | ssh $serverUser@$serverIP 'cat >> ~/.ssh/authorized_keys'
Add Comment
Please, Sign In to add comment