Can I input the password as a parameter to SCP rather than be prompted for it?
How can I save password,when copy a file using SCP? This question is similar, but answers deal with doing away with SSH password completely.
Can I input the password as a parameter to SCP rather than be prompted for it?
How can I save password,when copy a file using SCP? This question is similar, but answers deal with doing away with SSH password completely.
There are several options:
Execute the command:
sshpass -p 'password' scp filename user@host:
Install sshpass:
sudo apt install sshpass
sshpass - noninteractive ssh password provider
sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode.
ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling it into thinking it is getting the password from an interactive user.
The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just as well be any other command. The password prompt used by ssh is, however, currently hardcoded into sshpass.
write a script which will inject the password once it will identify the ssh password prompt
IMHO - This is the most secure way, and it doesn't require using passwords.
Using public/private key in order to perform ssh
or scp
operation without having to enter a password.
More info can be found in this answer
Detailed information can be found here
There is already an answer on how to do it, so I will focus on why not.
ps
or any other process lister.Instead use a public/private key, and use an key agent to temporarily remember your key.