How to use SCP to transmit without asking?

When using SCP to transfer files in linux, there will always be "192.168.1.1 is not in the trusted hosts file."
How to avoid this problem when using command?
I don't want to install other programs to proceed, I hope it can be presented through scp.

thanks!

The question should only be asked once.

And it's a scp client side 'issue', not openwrt.

1 Like

When you connect the first time the host fingerprint would be stored in .ssh/known_hosts if that is not happening you need to check the client.

2 Likes

Can't it be like "ssh -y" ? -- don't perform any remote host key checking

Googled/Tried man scp ?

2 Likes

yes, I tried scp -o StrictHostKeyChecking=no and other options, but it didn't work
it only work from windows.

I use ssh-keyscan to fetch the public key. I have the following commands in a setup script I use:

ssh-keyscan -H $host,$ip4 >> ~/.ssh/known_hosts
ssh-keyscan -H $host >> ~/.ssh/known_hosts
ssh-keyscan -H $ip4 >> ~/.ssh/known_hosts

Refer to the man page. I'm including the security section below:

Security: If an ssh_known_hosts file is constructed using ssh-keyscan without verifying the keys, users will be vulnerable to man in the middle attacks. On the other hand, if the security model allows such a risk, ssh-keyscan can help in the detection of tampered keyfiles or man in the middle attacks which have begun after the ssh_known_hosts file was created.

5 Likes