How to give password in shell script?

Jeegar Patel picture Jeegar Patel · Feb 20, 2012 · Viewed 32.2k times · Source

In a shell script file I am using some commands like scp and make install which ask for my password.

I run a shell script to compile a big project, and after some time it asks for my password for using scp. I need to wait for that process and give the password after that.

I just want to do it all by shell script without interaction, so how can I avoid being prompted for the password here?

Answer

Kimvais picture Kimvais · Feb 20, 2012

Short answer: DON'T

Use public key authentication for SCP and sudo with NOPASSWD directive for make install