LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2015, 03:00 PM   #1
sona1111
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Rep: Reputation: Disabled
Python - Problem providing ssh passphrase with PEXPECT


Hello community. I come seeking help only after many hours of research, so I would be very appreciative if anyone has any ideas regarding this issue.

I develop some programs which usually run on the ubuntu 14.04 server platform. A small part of one of the python programs involved automatically setting up an sshfs mounting for a user. The user will already have a public key file installed on the remote machine. Sometimes, the key files have passphrases, which I will get from the user (either at the time or stored). On ubuntu, the following code worked correctly to set up the mounting if they had a passphrase:

Code:
proc = pexpect.spawn('sshfs %s@%s:%s...') #many options
      proc.expect([pexpect.EOF, 'Enter passphrase for key.*', pexpect.TIMEOUT], timeout=30)
      if proc.match_index == 1:
          proc.sendline('thepassphrase')
Now for annoying reasons I must move the application to a RHEL 6.5 server. I have managed to solve most/all of the problems except this one. The above code seemingly never enters the passphrase. I have tried waiting, entering twice, many other things. But I do get EOF after entering the first time, as expected, the process just does not work. I believe part of the problem is the openssh version. RedHat currently only supports up to 5.3, yet 6.6 was installed on the ubuntu server I was working with. (also, SSHFS on redhat is 2.4 while on ubuntu it is 2.5)

The issue, stated explicitly, is that the mounter folder is listed as 'transport endpoint is not connected'. This is usually a sign that the sshfs command was interrupted in the middle.

SElinux is disabled, and of course the offending command works find if run manually.

Thank you for any insight you may have!
 
Old 03-06-2015, 05:21 PM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Have you tried doing this from the command line following those steps?
I only ask because my RHEL instances always ask my expect scripts "Enter Your LAN Password:".
 
Old 03-08-2015, 04:58 PM   #3
sona1111
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thank you for the reply.

Yes, I have verified that everything works fine is I enter the exact same command, and enter the passphrase. I also know that pexpect catches the event that asks for the passphrase, and seemingly it tries to enter the passphraseas well, but upon entering it gets an instant EOF (as opposed to on ubuntu, where it lags usually one or two seconds before the EOF.) This leaves things in a state where it seems like the process had received a SIGINT.

One piece to note: another part of the program checks if a passphrase is correct using the ssh-keygen binary, and this still works perfectly fine.

I tried, as a workaround, to remove the passphrase, run sshfs, and then add the passphrase again. This has also worked fine on ubuntu but not redhat. On redhat the problem is different though: the sshfs process just lags forever and pexpect issues a timeout error....

Redhat can be strange.
 
  


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
LXer: Python modules you should know: pexpect LXer Syndicated Linux News 0 04-27-2012 02:41 PM
pexpect python help rohit_k Programming 0 12-02-2011 07:16 AM
LXer: HowTo Manage your networked devices using Python and Pexpect LXer Syndicated Linux News 0 09-28-2009 02:40 PM
python: pexpect problems? Chowroc Programming 0 03-02-2006 11:08 PM
ssh / ssh-key -- its always asking for passphrase BaerRS Linux - General 1 01-07-2003 06:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:55 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