Advertisement
Guest User

Untitled

a guest
Mar 25th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. ssh -t $userHost -p $remotePort
  2. "for localUser in $(ls /home | grep -v $USER);
  3. do sudo -S mkdir -p /home/$localUser/.ssh &&
  4. cat /home/$USER/.ssh/authorized_keys | sudo tee --append
  5. /home/$localUser/.ssh/authorized_keys > /dev/null; done"
  6.  
  7. #!/bin/bash
  8.  
  9. userHost="user@host.example"
  10. remotePort="1234"
  11. password="password"
  12.  
  13. # Send public key to remote host
  14. echo "Sending public key to remote host..."
  15. cat "$HOME/.ssh/id_rsa.pub" | ssh $userHost
  16. -p $remotePort "cat >> ~/.ssh/authorized_keys"
  17.  
  18. # Add the public key to all users on the remote system
  19. ssh $userHost -p $remotePort 'echo '"$password"' | sudo -S
  20. ls /home/ && for localUser in $(ls /home | grep -v $USER);
  21. do sudo mkdir -p /home/$localUser/.ssh &&
  22. sudo touch /home/$localUser/.ssh/authorized_keys &&
  23. sudo chown "$localUser:$localUser" /home/$localUser/.ssh/authorized_keys &&
  24. cat /home/$USER/.ssh/authorized_keys | sudo tee
  25. --append /home/$localUser/.ssh/authorized_keys > /dev/null; done'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement