LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-14-2006, 03:43 AM   #1
ebel.velda
LQ Newbie
 
Registered: Jun 2006
Posts: 17

Rep: Reputation: 0
scp, how to pass password in script


Problem :
I have to transfer a file to many maschines.
I do not want to use key pairs, but scp.
How do I pass the password into the script? I do not mind that password stands in a script, it is OK.
I know about EXPECT, and have made it work, but only for one loop (see below)and I need it to work on 20 maschines....
Help would bne greatly valued!
My scripts :
With EXPECT :
*************************
set nalog username
set lozinka password
set fajl bla-bla
spawn scp -p -v /root/nalog/$fajl $nalog@10.66.3.222:/home/$nalog
expect "$nalog@IP address's password:"
send "$lozinka\r"
interact
**************************
When I try to make another (same definition) process towards another maschine, it does not work any more. So how do I make multiple scp-s with EXPECT (all different IP, username and pass)?

With SCP :
**************************
nalog=username
lozinka=pasword
echo Name of the file to transfer :
echo $fajl
scp -2 -4 -v /root/nalog/$fajl $nalog@IP address:/home/$nalog
*************************
When I try to make the script take the password here (and belive me, I have tried echo, piping, etc) it does not work any more


HELP!!!!
Velda
 
Old 09-14-2006, 10:34 AM   #2
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
the obvious attempt would be to try to pipe your password to the standard input of scp

> echo "password" | scp file user@host:/dir/to/copy/to

but this won't work because scp doesn't read from the standard input because is designed not to allow the user to do things like pass the password through standard input.
 
Old 09-14-2006, 09:11 PM   #3
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Why don't you want to use key pairs? Apart from being much more secure, SCP is designed to use them for passwordless logins:
Code:
scp -i ~/.ssh/ssh_key localFile user@remoteHost:/path/to/remoteFile
I have some information about setting up SSH public/private key pairs Here

I hope this helps
--Ian
 
Old 07-17-2007, 04:59 PM   #4
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
Quote:
Originally Posted by IBall
Why don't you want to use key pairs? Apart from being much more secure, SCP is designed to use them for passwordless logins:
Code:
scp -i ~/.ssh/ssh_key localFile user@remoteHost:/path/to/remoteFile
I have some information about setting up SSH public/private key pairs Here

I hope this helps
--Ian
has someone more information, how to quickly use : expect ??
(easy, simple, fast and secured)
 
Old 07-17-2007, 05:13 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might want to read up on using ssh-agent and ssh-add for this. The idea is that you just need to supply your password once when you start your session. It is more secure doing this to cache your passphrase, then passwordless logins, in the case that one of the remote servers is compromised or you don't trust the root user on that server.

Last edited by jschiwal; 07-17-2007 at 05:19 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp without password not reliable joanna Linux - Security 2 12-17-2005 10:23 PM
Pass SCP User passward in shell program michaelyu33 Programming 3 03-18-2005 12:15 PM
scp, don't prompt password!! dlublink Linux - Networking 1 01-03-2005 12:54 PM
pass root password in cgi script file explorer Linux - General 3 04-06-2004 10:13 PM
scp and no password mikeyt_333 Linux - General 2 03-26-2002 03:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:48 PM.

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