{"action":"created","issue":{"url":"https://api.github.com/repos/pexpect/pexpect/issues/192","labels_url":"https://api.github.com/repos/pexpect/pexpect/issues/192/labels{/name}","comments_url":"https://api.github.com/repos/pexpect/pexpect/issues/192/comments","events_url":"https://api.github.com/repos/pexpect/pexpect/issues/192/events","html_url":"https://github.com/pexpect/pexpect/issues/192","id":64267639,"number":192,"title":"SSH Passphrase input fails strangely in rhel 6.5-6.6","user":{"login":"sona1111","id":4585193,"avatar_url":"https://avatars.githubusercontent.com/u/4585193?v=3","gravatar_id":"","url":"https://api.github.com/users/sona1111","html_url":"https://github.com/sona1111","followers_url":"https://api.github.com/users/sona1111/followers","following_url":"https://api.github.com/users/sona1111/following{/other_user}","gists_url":"https://api.github.com/users/sona1111/gists{/gist_id}","starred_url":"https://api.github.com/users/sona1111/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sona1111/subscriptions","organizations_url":"https://api.github.com/users/sona1111/orgs","repos_url":"https://api.github.com/users/sona1111/repos","events_url":"https://api.github.com/users/sona1111/events{/privacy}","received_events_url":"https://api.github.com/users/sona1111/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-25T13:25:30Z","updated_at":"2015-03-26T02:25:08Z","closed_at":null,"body":"I have been trying to resolve this issue through various communications (ex. http://stackoverflow.com/questions/28823639/how-to-automatically-input-ssh-private-key-passphrase-with-pexpect) , but I have not had success for a significant time duration so I am trying to ask at the source now. As part of a program I need to automatically enter a passphrase for an SSH key. I built a simple pexpect script such as, which should mount via sshfs:\r\n\r\n    proc = pexpect.spawn('sshfs %s@%s:%s -o identityfile=...') #many options, unrelated\r\n    proc.expect([pexpect.EOF, 'Enter passphrase for key.*', pexpect.TIMEOUT], timeout=30)\r\n    if proc.match_index == 1:\r\n        proc.sendline('thepassphrase')\r\n\r\nOn ubuntu server distributions, this works correctly, but when switching to rhel 6.5 or 6.6 (ones I have tested so far) I get the issue. What happens is that the 'enter passphrase for key' is caught and the line is seemingly sent, but then the process exits before the mounting is complete. I get the 'transport endpoint is not connected' error - an error that would happen if I tried running the command but then sent a SIGINT before entering the passphrase. I have tried various combinations of waits and communicates but after being on it for literally days I think it may just be a bug. \r\n\r\n(note that I do mean _passphrase_ and not _password_, I _am_ using a SSH private key, it just has a passphrase)\r\n\r\nLet me know if you need more information. "},"comment":{"url":"https://api.github.com/repos/pexpect/pexpect/issues/comments/86300156","html_url":"https://github.com/pexpect/pexpect/issues/192#issuecomment-86300156","issue_url":"https://api.github.com/repos/pexpect/pexpect/issues/192","id":86300156,"user":{"login":"jquast","id":972584,"avatar_url":"https://avatars.githubusercontent.com/u/972584?v=3","gravatar_id":"","url":"https://api.github.com/users/jquast","html_url":"https://github.com/jquast","followers_url":"https://api.github.com/users/jquast/followers","following_url":"https://api.github.com/users/jquast/following{/other_user}","gists_url":"https://api.github.com/users/jquast/gists{/gist_id}","starred_url":"https://api.github.com/users/jquast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jquast/subscriptions","organizations_url":"https://api.github.com/users/jquast/orgs","repos_url":"https://api.github.com/users/jquast/repos","events_url":"https://api.github.com/users/jquast/events{/privacy}","received_events_url":"https://api.github.com/users/jquast/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T02:25:08Z","updated_at":"2015-03-26T02:25:08Z","body":"I got the VDI, thank you, I was able to reproduce.\r\n\r\nI don't understand the cause, but I thought I'd reply with a workaround anyway since you seem to be struggling -- with the given example script, ``sshfs`` process does not remain after exit.\r\n\r\nA simple enough workaround is to spawn an *interactive* bash shell, send the command sequence and exit nicely:\r\n\r\n**sshfs process remains after exit**\r\n\r\n```\r\n\r\npassphrase = 'some passphrase'\r\ncmd = \"sudo -H -u somebody sshfs somebody@somewhere:/somewhere-else /home/somebody/testmount -o StrictHostKeychecking=no -o nonempty -o reconnect -o workaround=all -o IdentityFile=/somekey -o follow_symlinks -o cache=no\"\r\n\r\nbash = pexpect.spawn('bash', echo=False)\r\nbash.sendline('echo READY')\r\nbash.expect_exact('READY')\r\nbash.sendline(cmd)\r\nbash.expect_exact('Enter passphrase for key')\r\nbash.sendline(passphrase)\r\nbash.sendline('echo COMPLETE')\r\nbash.expect_exact('COMPLETE')\r\nbash.sendline('exit')\r\nbash.expect_exact(pexpect.EOF)\r\n```\r\n\r\n**sshfs process does not remain after exit**\r\n\r\n```\r\nbash2 = pexpect.spawn('bash', ['-c', cmd])\r\nbash2.expect_exact('Enter passphrase')\r\nbash2.sendline(passphrase)\r\n```\r\n\r\nI have a feeling this has something to do with signals, such as SIGCHLD, but I don't know for sure."}}