I want to write a script in which I need to get the content of a file from different machine 192.168.0.2
without enterging the password so I used sshpass
with the following command :
sshpass -p "password" ssh -o StrictHostKeyChecking=no [email protected] " ls /root/path/of/file"
Output :
ls: cannot access '/root/path/of/file': Permission denied
I get it because I sidn't login as a root
user. So I tried :
sshpass -p "password" ssh -o StrictHostKeyChecking=no [email protected] "sudo ls /root/path/of/file"
Output :
sudo: no tty present and no askpass program specified
What should I do?