0

I am executing following steps to mount my server and copy the files. But it interrupts for password. How can I do it automatic ?

sudo apt install cifs-utils 

sudo mount -t cifs -o user=user.name //192.168.X.X/BAfolder  /media

cp -r /media/BAfolder/* /home/techy/Documents/files/
techy
  • 127

1 Answers1

1

Save the password in a file with highly restricted permissions in a restricted folder that only you can access. Cat the file out and pipe the output to sudo -S instead of plain sudo.

cat <folder>/file.secret | sudo -S mount -t cifs -o user=user.name //192.168.1.21/BAfolder  /media

store the password in a shell variable export password=X and then echo it

echo $password' | sudo -S mount -t cifs -o user=user.name //192.168.1.21/BAfolder /media
muru
  • 207,228
Kyle H
  • 1,064
  • 6
  • 7