LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-05-2005, 03:26 PM   #1
cli_man
Member
 
Registered: Apr 2002
Location: New York, USA
Distribution: Redhat 7.2, 9.0 Slackware 9.1
Posts: 428

Rep: Reputation: 30
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 myuser:mypass@www.myserver.edu:/var/www/mysite/myfile.txt

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

Thank You.
 
Old 08-05-2005, 03:47 PM   #2
timcharper
Member
 
Registered: May 2005
Location: Utah
Distribution: Fedora Core 4
Posts: 36

Rep: Reputation: 15
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
~/.ssh/id_dsa.pub

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

now, on machineB, logged into the desired account:
type "cat ~/id_dsa.pub >> ~/.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

Last edited by timcharper; 08-05-2005 at 03:51 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh/scp without password not working Mauline Linux - Security 4 03-30-2005 09:26 PM
scp, don't prompt password!! dlublink Linux - Networking 1 01-03-2005 12:54 PM
How to include password with su-command? Ollir Mandriva 2 08-16-2004 05:17 AM
scp still ask for root 's password when executing... Laplace Linux - General 1 03-02-2003 07:45 AM
scp and no password mikeyt_333 Linux - General 2 03-26-2002 03:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration