linux - Is it possible to automatically input value to the terminal when using an ssh connection? -
i have username, ip addresses , passwords specific servers. want connect these servers using sshpass ssh connection. first connection these servers, ssh save fingerprints. need write code handle prompt asking me if want continue connecting , password.
the problem since new connection, prompt if want continue , don't want type "yes" every server. dealing on 50 servers @ 1 point , don't want manually type "yes" , password.
this (dummy) code of have in bash:
ip="192.168.111.111" user="user" password="password" sshpass -p $password $user@$ip "exit" i error of host key verification failed code.
so tried: $user@$ip "exit" , prompt asking me want continue connecting (yes/no). don't want type "yes" each time , password each server. can have code can manually you?
thanks. let me know if further explanation required. also, want avoid using expect tool.
you can disable host key checking adding option ~/.ssh/config under relevant hostnames
host xxx.xxx.xxx.xxx stricthostkeychecking no you can use wildcards match ranges of ips (for example host * used global setting). option in config, should able use command:
sshpass -p"$password" ssh "$user"@"$ip" if prefer not edit config file, can specify option on command line instead:
sshpass -p"$password" ssh -o stricthostkeychecking=no "$user"@"$ip" note normally, recommended use ssh keys rather passwords authenticate in kind of scenario, facilitates automatic processes otherwise require prompt. can more secure, means password isn't stored in plaintext somewhere.
Comments
Post a Comment