-   Linux - General (
-   -   Include scp password in command (

cli_man 08-05-2005 04:26 PM

Include scp password in command
I have a perl script that needs to scp a file from one machine to another, I cannot used a public key or anything like that, I would like to be able to include the password in the scp command but I don't know the syntax for that. I thought it was something like:

scp myfile.txt

But that does not work. Does anyone have a suggestion?

Thank You.

timcharper 08-05-2005 04:47 PM

to my knowledge, there isn't anyway to provide a password to scp. That doesn't mean there isn't a way... of course... it just means I don't know how :P If there is a way, I would love to know!

I've had to do the same thing. What I ended up doing is creating a ssh keypairs. An ssh keypair allows you to connect to another machine with out having to provide a password

Creating them is easy.

machineA is the source machine, machineB is the machine you want to connect to passwordlessly. account is the desired account you wish to connect to without a password.

On machineA:
type "ssh-keygen -t dsa"

use the default option for each, and don't provide a passphrase for the key (as that would defeat the purpose of what we are trying to accomplish)

now, if you did the default options, that should have created two files in on MachineA in ~/.ssh/id_dsa

now, you can type this to copy the key
scp ~/.ssh/ account@machineB:~/

now, on machineB, logged into the desired account:
type "cat ~/ >> ~/.ssh/authorized_keys"

now you should be able to ssh/scp from machine "A" to machine "B" without providing a password!

NOTE:carefully guard the private key file id_dsa. If anyone got a copy of that, they could log into the machine "B" that you have authorized for that key pair.

Please correct me if I'm wrong with anything I've said here :)

All times are GMT -5. The time now is 02:14 PM.