Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ssh -t $userHost -p $remotePort
- "for localUser in $(ls /home | grep -v $USER);
- do sudo -S mkdir -p /home/$localUser/.ssh &&
- cat /home/$USER/.ssh/authorized_keys | sudo tee --append
- /home/$localUser/.ssh/authorized_keys > /dev/null; done"
- #!/bin/bash
- userHost="user@host.example"
- remotePort="1234"
- password="password"
- # Send public key to remote host
- echo "Sending public key to remote host..."
- cat "$HOME/.ssh/id_rsa.pub" | ssh $userHost
- -p $remotePort "cat >> ~/.ssh/authorized_keys"
- # Add the public key to all users on the remote system
- ssh $userHost -p $remotePort 'echo '"$password"' | sudo -S
- ls /home/ && for localUser in $(ls /home | grep -v $USER);
- do sudo mkdir -p /home/$localUser/.ssh &&
- sudo touch /home/$localUser/.ssh/authorized_keys &&
- sudo chown "$localUser:$localUser" /home/$localUser/.ssh/authorized_keys &&
- cat /home/$USER/.ssh/authorized_keys | sudo tee
- --append /home/$localUser/.ssh/authorized_keys > /dev/null; done'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement