Search code examples
linuxbashshellscpexpect

Using 'expect' to automatically send in password


I am trying to copy a file from my remote server to my local. Here's my script to run it, by using 'expect' to automaticlally send in password

scp user@host:/folder/myFile ./
expect "Password: "
send "myPassword"

When I run this, it still prompts for "Password", what is wrong?


Solution

  • From what you are trying to do it sounds like you might be better off using ssh with a public and private key. You could google for ssh-keygen tutorial to get started.