Execute ssh command without password?
7,191
Solution 1
No problem. Make keys without a password: http://linuxproblem.org/art_9.html
Solution 2
If ssh server not support publickey, use expect script
#!/usr/bin/expect -f
set ipaddr [lrange $argv 0 0]
spawn ssh admin@$ipaddr
expect "Password:"
sleep 1
send "PASSWORD\r"
interact
And run
./script hostname
Related videos on Youtube
Author by
coderlearner
Updated on September 17, 2022Comments
-
coderlearner almost 2 years
I execute the following command:
ssh -l admin hostname command
Each time I execute it, I am asked to enter a password. How can I automatically provide it with a password since I am going to put this in a bash script?
-
Zoredache over 13 yearsThe standard method to accomplish something like this is to use [key-based authentication][serverfault.com/search?q=ssh+key+authentication]. Follow the link to see lots of SF questions on the topic.
-