
Ssh copy id no known hosts password#
If it didnt ask for a password it worked. for server in cat server.txt do sshpass -p 'password' ssh-copy-id -i /.ssh/idrsa.pub userserver done This requires sshpass, which may need to be installed separately, either via package or from source. And save Ctl+O, exit the file Ctl+X, exit the SSH session exit and try logging back in to confirm it worked. Here is my simple script to copy ssh-keygen to multiple servers without asking password everytime. Then edit the /etc/ssh/sshd_config with whatever text editor you prefer and change the line PermitTootLogin yes to NO well actually just no. Then edit authorizedkeys on the server and paste contents of your clipboard below any other keys in that file: nano /.ssh/authorizedkeys. OH and before you forget best turn off ssh access to root to do so:įirst confirm you can ssh using your new user. Not hard at all and you dont compromise your security! Hope I helped someone! Just tested this on Ubuntu 16.04 works like a charm! Now you can shh to your droplet with the new user I just sent my idrsa.pub to another dev to get access to a server.

This can result in multiple copies of the key in authorizedkeys files. The options have the following meaning:-f Don't check if the key is already configured as an authorized key on the server. Now simply copy and past the contents of your public key to this file and save it with ctrl+w The sample below presents ssh-copy-id command line syntax: ssh-copy-id -f -n -i identity file -p port -o sshoption userhostname.
Once your signed in change directory to your default directory with the command: If you see the message ssh: connect to host
I gotta say I am disappointed in most of you turning on Password Authentication is a MISTAKE DONT DO IT!ĭo this instead just create your user using root then sign in as the NON ROOT user using the su userhere command.
