LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 09-16-2007, 09:53 PM   #1
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Rep: Reputation: 15
using sftp with password


Hey guyz,
i need to use sftp with a password.. not with the open ssh keygen.

i tried this


FTPDESTI=$USER@$ip

sftp -b $FILE root@ip << EOF
EOF

in the file $FILE it contains:
password
ls

any idea where i go wrong?
 
Old 09-16-2007, 10:09 PM   #2
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 57
doesn't sftp normally have a password?
 
Old 09-16-2007, 10:14 PM   #3
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Original Poster
Rep: Reputation: 15
i am writing a script on it....
i wanna go in through sftp with a password,,,
how do i put the sftp password in the script?
 
Old 09-17-2007, 03:39 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
As far as I'm concerned there is no way to do that by means of the sftp command. Apart security concerns which you may have taken into account, a method can be using expect, which talk to interactive applications. For example the script
Code:
#!/usr/bin/expect
spawn  sftp -b batchfile user@ipaddress
expect "password:"
send "userpassword\n";
interact
talk to sftp by sending the password in the colored field. Please note first line of this script and the newline character after the password. Expect is not installed by default on all linux distros. Another method could be by means of Perl or Python, which can interact with sftp passing arguments like password and commands.
 
Old 09-17-2007, 09:34 PM   #5
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Original Poster
Rep: Reputation: 15
hmmm.....
if i do not have expect in /usr/bin.. where do i go to get it?
 
Old 09-17-2007, 09:39 PM   #6
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 57
Quote:
Originally Posted by colucix View Post
As far as I'm concerned there is no way to do that by means of the sftp command. Apart security concerns which you may have taken into account, a method can be using expect, which talk to interactive applications. For example the script
Code:
#!/usr/bin/expect
spawn  sftp -b batchfile user@ipaddress
expect "password:"
send "userpassword\n";
interact
talk to sftp by sending the password in the colored field. Please note first line of this script and the newline character after the password. Expect is not installed by default on all linux distros. Another method could be by means of Perl or Python, which can interact with sftp passing arguments like password and commands.
if the password is in clear text then wouldn't this be pretty insecure
 
Old 09-17-2007, 10:23 PM   #7
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Original Poster
Rep: Reputation: 15
hmm i want something like that example he give hmm unless there is a better way.. cause its just for house keeping.. no biggie
 
Old 09-17-2007, 11:10 PM   #8
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 57
I would encrypt the password rather then storing it in clear text
 
Old 09-18-2007, 01:00 AM   #9
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Quote:
Originally Posted by AceofSpades19 View Post
if the password is in clear text then wouldn't this be pretty insecure
I know. If you re-read my post you can see I assume the OP has done his evaluation about security concerns. As for me, I would use public key authentication.
Quote:
Originally Posted by ryanlum
if i do not have expect in /usr/bin.. where do i go to get it?
Depending on the distribution you are running on, you should be able to find a package called expect. The official page is here.
 
Old 09-18-2007, 01:00 AM   #10
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Original Poster
Rep: Reputation: 15
hmm right...
so how do i get this method to work??
 
Old 09-18-2007, 02:27 AM   #11
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Which linux are you running on?
 
Old 09-18-2007, 02:33 AM   #12
ryanlum
Member
 
Registered: Jul 2007
Posts: 47

Original Poster
Rep: Reputation: 15
hmmmm
red hat linux 9
hmm
but some colleauges of mine changed the kernal
 
Old 09-18-2007, 05:04 PM   #13
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Hmmm... I doubt that a RPM for RedHat9 is available somewhere. You may consider to compile from source (see the link I posted).
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve( or reset) root password in Mandrake Linux, as I forgot my password? Reghunath Linux - Software 4 05-08-2008 04:11 AM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
How can I change e-mail password(or linux account password) with php in website?? yusuf Programming 1 05-28-2004 09:39 AM
Eclipse IDE with Klomp Sftp Plugin, can't change password mikeyt_333 Linux - Software 1 05-14-2004 06:42 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 10:29 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration