LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-04-2009, 02:52 AM   #1
maxy7710
Member
 
Registered: Jan 2008
Location: Mumbai, india
Distribution: REDHAT, FEDORA,SUSE, UBUNTU, ORACLE ENTERPRISE LINUX & SOLARIS 10
Posts: 130

Rep: Reputation: 17
hardcoding scp password


hi i want to hardcode a scp password with the scp command.

i dont want to do scp without password using rsa key.

i want to add this top a script, so that when script runs, it should transfer file without password & when others try to do it then they should be asked for the password.
 
Old 08-04-2009, 07:42 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
When using common sense / by searching LQ you'll find that hardcoding passwords is not a best practice because regardless of the way you code it, it will be exposed and it can be read. Have you considered using ssh-agent? If that is not an answer please elaborate why you think you need hardcoding passwords in the first place.
 
Old 08-05-2009, 12:31 AM   #3
maxy7710
Member
 
Registered: Jan 2008
Location: Mumbai, india
Distribution: REDHAT, FEDORA,SUSE, UBUNTU, ORACLE ENTERPRISE LINUX & SOLARIS 10
Posts: 130

Original Poster
Rep: Reputation: 17
Guys here's a way to do it.

i know its secure, but its just the need of current requirement.

Going for rsa keys is a better option.

I hope this helps someone....someday......tc


#!/bin/bash
echo $SHELL
/usr/bin/expect <<EOF
set timeout -1
spawn scp /root/data root@172.17.115.149:/home/admin/
expect {
(yes/no)? {send "yes\r" ; exp_continue}
echo Hai
password: {send "redhat\r" ; exp_continue}
eof exit

}
 
Old 08-05-2009, 06:17 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Mitigating circumstances (LAN) or not, anyone using this should realise that best practices don't include:
- SSH as root account user,
- Hardcoding passwords,
- Using weak password policies.
 
Old 08-05-2009, 12:11 PM   #5
visu_kvg
LQ Newbie
 
Registered: Aug 2009
Location: HYD,India
Distribution: RHEL
Posts: 19

Rep: Reputation: 0
Use autoexpect dude!

Last edited by visu_kvg; 08-06-2009 at 03:09 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 needs three times password in wrong password case!!! JATA01 Programming 6 12-01-2008 06:28 AM
SSH/SCP with no password wh33t Linux - Software 11 06-10-2007 12:38 AM
SCP without Password help ignignokt Linux - Networking 3 01-02-2007 12:59 PM
scp, don't prompt password!! dlublink Linux - Networking 1 01-03-2005 01:54 PM
scp and no password mikeyt_333 Linux - General 2 03-26-2002 04:33 PM


All times are GMT -5. The time now is 10:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration