I am trying to copy several files from a remote server into local drive in Bash using scp. Here's the part of the code
scp -r -q $USR@$IP:/home/file1.txt $PWD
scp -r -q $USR@$IP:/home/file2.txt $PWD
scp -r -q $USR@$IP:/root/file3.txt $PWD
However, the problem is that EVERY time that it wants to copy a file, it keeps asking for the password of the server, which is the same. I want it to ask only once and then copy all my files.
And please, do not suggest rsync nor making a key authentication file since I do not want to do that. Are there any other ways...? Any help would be appreciated
You can use expect script or sshpass
sshpass -p 'password' scp ...
#!/usr/bin/expect -f
spawn scp ...
expect "password:"
send "ur_password"
An disadvantage is that your password is now in plaintext
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With