passing yes argument while scp command passing yes argument while scp command bash bash

passing yes argument while scp command


scp -o StrictHostKeyChecking=no root@IP:/root/K 

Obviously, this isn't a very secure solution. Works for one-shots where you're not concerned about man in the middle, though.


For me, this works:

 yes | scp -r /opt/MyFiles root@<MyNewServerIP>:/opt/MyFiles

Regards. =)


Probably the best way to do this would be to use the following command before your scp command:

ssh-keyscan -H ${SSH_HOST} >> ~/.ssh/known_hosts

This will add the SSH_HOST to your known hosts and scp will not complain. Substitute ${SSH_HOST} for the IP address you are trying to connect to.