I'm writing a script to automate running a specific command across multiple Linux systems. I am going to use something like:
read -s "Enter password" ANS
sshpass -p $ANS ssh server "some command"
Is there going to be a security concern on this?
I'm writing a script to automate running a specific command across multiple Linux systems. I am going to use something like:
read -s "Enter password" ANS
sshpass -p $ANS ssh server "some command"
Is there going to be a security concern on this?
Your password, and any other command line arguments, will be visible to anyone else on the system using the ps command. A better alternative would be to use SSH key based login? Official Doc
The sshpass man page has a whole section on the security implications.
Users of sshpass are encouraged to use one of the other password passing techniques, which are all more secure.
In particular, people writing programs that are meant to communicate the password programatically are encouraged to use an anonymous pipe and pass the pipe's reading end to sshpass using the -d option.
So, if you must pass a password, they encourage the use of an anonymous pipe. You could also save the password to a file and use the -f
flag instead.
If you're interested in security, key-based authentication is the best option. Sometimes this isn't reasonable as your target(s) has a lack of extra non-volatile memory to store a public key, but you should try to set up key-based auth if you can.