LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-15-2007, 08:27 AM   #1
kennmurrah
LQ Newbie
 
Registered: May 2005
Posts: 20

Rep: Reputation: 0
scripting a password for scp


I want to write a short script that will, among other things, copy some files to a different server via scp. Doing this from the command line is easy, but if I want to script it, how do I incorporate the password into my script so that I can run it without being asked for the password (e.g. via cron)?

Thanks.

Kenn
 
Old 10-15-2007, 08:40 AM   #2
whitemice
Member
 
Registered: Aug 2007
Location: Michigan, USA
Distribution: openSUSE
Posts: 52

Rep: Reputation: 15
Don't

Quote:
Originally Posted by kennmurrah View Post
I want to write a short script that will, among other things, copy some files to a different server via scp. Doing this from the command line is easy, but if I want to script it, how do I incorporate the password into my script so that I can run it without being asked for the password (e.g. via cron)?
Kenn
Don't!

SSH supports certificate authentication, and this is widely used and documented. Just generate an SSH key pair, put your public key on the server you are SCPing to and SCP & SSH will no longer as for a password as you will be 'pre-authenticated'.
 
Old 10-15-2007, 09:01 AM   #3
kennmurrah
LQ Newbie
 
Registered: May 2005
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks for the response ... two questions.

1. If I want to throw caution to the wind and do it, is it possible?

2. Could you point me in the direction of a how to that would help me do it your (proper) way?

thanks again.

Kenn
 
Old 10-15-2007, 09:43 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
For the proper way, you should set up public key authentication. Here's how.

The "wrong" way to do it is to use expect. expect is a library which allows a program to pretend to be a user at a terminal, watch for patterns in the output of the program which is being run, and send commands accordingly. It can also attach the real user to the program. This is, in general the wrong approach for login automation as expect will have to store the account password somewhere, and this is very difficult to do in a secure way.
 
Old 10-15-2007, 09:47 AM   #5
kennmurrah
LQ Newbie
 
Registered: May 2005
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks to all.

Kenn
 
  


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
SSH/SCP with no password wh33t Linux - Software 11 06-09-2007 11:38 PM
SCP without Password help ignignokt Linux - Networking 3 01-02-2007 11:59 AM
scp, don't prompt password!! dlublink Linux - Networking 1 01-03-2005 12:54 PM
scripting a find, cp and bzip2 then scp process onewhoknows Linux - Newbie 2 06-08-2004 06:05 AM
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 05:43 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