[Linux] Input password automatically
In this post, I will introduce an approach to input password programatically, which is useful if a repeated command needs password.
Note: this approach is subject to the risk of exposing your passwords to others, so use it with caution.
Let’s use sudo as an example. Normally when you type
|
|
It will prompt for a password if you set one.
However, if you type
|
|
Then the passord is fed into the command directly. Here the command sshpass is from a package sshpass, which can be installed with
|
|
Hope that this tip helps.
Last modified on 2019-10-07