Enter Password through bourne shell script when asked by the command without expect

StackOverflow https://stackoverflow.com/questions/23588645

  •  19-07-2023
  •  | 
  •  

Question

I am writing a bourne shell script for the openwrt firware where I want to copy my files from router to linux machine. when i do

scp /etc/clients.txt shah@192.168.1.2:/home/shah/

from inside the router's openwrt firmware, it asks me to give the password. I want to give this password from within the script because this file needs to be copied after every 2 seconds. How can I do this without using expect?

Was it helpful?

Solution

You can try to use sshpass tool but you will need to provide a password in clear text in your script. If that is not a problem you should use it.

sshpass -p 'password'  scp /etc/clients.txt shah@192.168.1.2:/home/shah/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top