I am trying to transfer some files using SCP in a shell script, but I am being prompted for my password on the remote machine.
Can I use expect with scp to enter the password so I don't have to type it in all the time?
I am trying to transfer some files using SCP in a shell script, but I am being prompted for my password on the remote machine.
Can I use expect with scp to enter the password so I don't have to type it in all the time?
You don't. Use a key instead.
Yes, you can.
#!/usr/bin/bash
/usr/bin/expect <<EOD
spawn /usr/bin/scp -l 200 file.ext user@server://path/on/server/
expect "password:"
send "YourPassword\r"
expect "\r"
send "\r\n"
EOD
You can not bypass prompt by SCP.
What you can do to enter without passphrase is to use identity file. You can do this by setting up an Identity key. Instead of using password prompt you specify the location of identity file. If you need information about how to set this up , please use the given link : https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server