1

i could not find any examples on how i can set a password using scp to transfer files remotely via from command like

http://www.garron.me/en/linux/scp-linux-mac-command-windows-copy-files-over-ssh.html

currenty wrote this:

scp “/localFolder/localFile.txt” userName@172.11.111.345:”/RemoteFiolder/AA/”

Where do i enter the password on this script that wil run automatically?

Jonathan
  • 16,547
  • 47
  • 128
  • 211

3 Answers3

3

Generate a key using: ssh-keygen -t rsa -C "your_email@example.com"

Your public key has been saved in ~/.ssh/id_rsa.pub. Get that key and put it into ~/.ssh/authorized_keys on your remote box. To add multiple keys, add one per line.

et voilà, passwordless login available with that key (as long as you do not protect it with a password)

Rei
  • 86
  • 2
2

You cannot just enter the password this way. There is a utility though that can automate handle the "password feeding". Install the expect programm and write a script like this:

#!/usr/bin/expect

spawn scp “/localFolder/localFile.txt” userName@172.11.111.345:”/RemoteFiolder/AA/”

expect "yes/no" {

    send "yes\n"

    expect "*?assword" { send <your_pass>\n }

    } "*?assword" { send <your_pass>\n }

interact
sestus
  • 1,825
  • 2
  • 16
  • 16
1

The password prompt cannot be automated for security reasons, but you could use public key authentication for this.

See the ssh-keygen(1) manual for details.

Simon Richter
  • 27,324
  • 1
  • 40
  • 62