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

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

  •  19-07-2023
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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/
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top