LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   using sftp with password (https://www.linuxquestions.org/questions/linux-general-1/using-sftp-with-password-585183/)

ryanlum 09-16-2007 09:53 PM

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?

AceofSpades19 09-16-2007 10:09 PM

doesn't sftp normally have a password?

ryanlum 09-16-2007 10:14 PM

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?

colucix 09-17-2007 03:39 AM

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.

ryanlum 09-17-2007 09:34 PM

hmmm.....
if i do not have expect in /usr/bin.. where do i go to get it?

AceofSpades19 09-17-2007 09:39 PM

Quote:

Originally Posted by colucix (Post 2894359)
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

ryanlum 09-17-2007 10:23 PM

hmm i want something like that example he give hmm unless there is a better way.. cause its just for house keeping.. no biggie

AceofSpades19 09-17-2007 11:10 PM

I would encrypt the password rather then storing it in clear text

colucix 09-18-2007 01:00 AM

Quote:

Originally Posted by AceofSpades19 (Post 2895313)
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.

ryanlum 09-18-2007 01:00 AM

hmm right...
so how do i get this method to work??

colucix 09-18-2007 02:27 AM

Which linux are you running on?

ryanlum 09-18-2007 02:33 AM

hmmmm
red hat linux 9
hmm
but some colleauges of mine changed the kernal

colucix 09-18-2007 05:04 PM

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


All times are GMT -5. The time now is 04:51 AM.