Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an SSH RSA key auto accept?

Tags:

ssh

I need to check a bunch of servers via SSH (RAM, disk, CPU model, etc).

I want to make a script for it. But the RSA key yes/no is getting in the way.

Is it possible to auto accept the RSA key while connecting to the server via SSH?

(I.e. ssh root@ip "yes" or some workaround?)

like image 675
John Avatar asked Sep 01 '25 01:09

John


1 Answers

To tell ssh not to worry about host keys, simply set the StrictHostKeyChecking option to no, i.e.

ssh -o StrictHostKeyChecking=no root@ip

If you also want to pass the password to it, you can do that using sshpass:

sshpass -p your_password ssh -o StrictHostKeyChecking=no root@ip

However, you'd be much better off using an ssh agent (such as PAgeant) and ssh key pairs - better than having your password hard-coded into a script somewhere.

like image 139
IBam Avatar answered Sep 02 '25 19:09

IBam