{"action":"created","issue":{"url":"https://api.github.com/repos/ccontavalli/ssh-ident/issues/32","repository_url":"https://api.github.com/repos/ccontavalli/ssh-ident","labels_url":"https://api.github.com/repos/ccontavalli/ssh-ident/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/ccontavalli/ssh-ident/issues/32/comments","events_url":"https://api.github.com/repos/ccontavalli/ssh-ident/issues/32/events","html_url":"https://github.com/ccontavalli/ssh-ident/issues/32","id":174238625,"number":32,"title":"ssh-askpass required by ssh-ident","user":{"login":"mhoff","id":9436725,"avatar_url":"https://avatars.githubusercontent.com/u/9436725?v=3","gravatar_id":"","url":"https://api.github.com/users/mhoff","html_url":"https://github.com/mhoff","followers_url":"https://api.github.com/users/mhoff/followers","following_url":"https://api.github.com/users/mhoff/following{/other_user}","gists_url":"https://api.github.com/users/mhoff/gists{/gist_id}","starred_url":"https://api.github.com/users/mhoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhoff/subscriptions","organizations_url":"https://api.github.com/users/mhoff/orgs","repos_url":"https://api.github.com/users/mhoff/repos","events_url":"https://api.github.com/users/mhoff/events{/privacy}","received_events_url":"https://api.github.com/users/mhoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-31T10:29:08Z","updated_at":"2016-09-01T08:56:26Z","closed_at":null,"body":"When syncing some local stuff with my remote host `rsync` asks for the passphrase with `ssh-askpass`, even though this program is not installed on my system (I want to stick with this).\r\nAs  the program is not installed, adding the identity fails and the generic fallback identity is tried.\r\n\r\nI set up `ssh-ident` as an executable in my `$PATH`.\r\nThis is the output (`VERBOSITY = LOG_DEBUG`) I receive when running the `rsync` command:\r\n```\r\nrsync -e \"ssh -p 22\" -P -rvzc --delete $LOCAL_PATH $REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH [...]\r\nWill run '/usr/bin/ssh' as ssh binary - deteced from argv[0] and $PATH\r\nAgent for identity v8 ready\r\nLoading keys:\r\n    /home/mhoff/.ssh/identities/v8/id_rsa\r\nssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory\r\n+ . /home/mhoff/.ssh/agents/agent-v8-$HOSTNAME\r\n+ exec /usr/bin/ssh -oUseRoaming=no -p 22 -l $REMOTE_USER $REMOTE_HOST rsync --server -vrcCze.iLsfx --delete --partial . $REMOTE_PATH\r\nEnter passphrase for key '/home/mhoff/.ssh/id_rsa':\r\n```\r\nPlainly, adding the identity to the agent triggers `ssh-askpass`.\r\nI tracked down the following method being responsible in `ssh-ident`:\r\n```\r\n  @staticmethod\r\n  def RunShellCommandInAgent(agentfile, command):\r\n    \"\"\"Runs a shell command with an agent configured in the environment.\"\"\"\r\n    command = [\"/bin/sh\", \"-c\",\r\n               \". {0} >/dev/null 2>/dev/null; {1}\".format(agentfile, command)]\r\n    # command = ['/bin/sh', '-c', '. /home/mhoff/.ssh/agents/agent-v8-$HOST >/dev/null 2>/dev/null; ssh-add -t 14400 /home/mhoff/.ssh/identities/v8/id_rsa']\r\n    process = subprocess.Popen(command, stdout=subprocess.PIPE)\r\n    stdout, stderr = process.communicate()\r\n    return process.wait(), stdout\r\n```\r\nThe weird thing is that when I execute the above code in a standalone script everything works fine.\r\n\r\n**Script**\r\n```\r\n#!/usr/bin/python\r\nimport subprocess\r\nif __name__ == '__main__':\r\n    command = [\"/bin/sh\", \"-c\", \"/home/mhoff/.ssh/agents/agent-v8-$HOST >/dev/null 2>/dev/null; ssh-add -t 14400 /home/mhoff/.ssh/identities/v8/id_rsa\"]\r\n    process = subprocess.Popen(command, stdout=subprocess.PIPE)\r\n    stdout, stderr = process.communicate()\r\n```\r\n**Output**\r\n```\r\nEnter passphrase for /home/mhoff/.ssh/identities/v8/id_rsa: \r\n```\r\n\r\nIn the `rsync` command, I can add `-i $IDENTITY_PATH` to the `ssh` call.\r\nThen, the error still occurs, but the \"fallback\" identitiy is the given identity and the right prompt is used:\r\n```\r\nrsync -e \"ssh -p 22 -i ~/.ssh/identities/v8/id_rsa\" -P -rvzc --delete $LOCAL_PATH $REMOTE_HOST:$REMOTE_PATH [...]\r\nWill run '/usr/bin/ssh' as ssh binary - deteced from argv[0] and $PATH\r\nAgent for identity v8 ready\r\nLoading keys:\r\n    /home/mhoff/.ssh/identities/v8/id_rsa\r\nssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory\r\n+ . /home/mhoff/.ssh/agents/agent-v8-T420\r\n+ exec /usr/bin/ssh -oUseRoaming=no -p 22 -i ~/.ssh/identities/v8/id_rsa -l $REMOTE_USER $REMOTE_HOST rsync --server -vrcCze.iLsfx --delete --partial . $REMOTE_PATH\r\nEnter passphrase for key '/home/mhoff/.ssh/identities/v8/id_rsa': \r\n```"},"comment":{"url":"https://api.github.com/repos/ccontavalli/ssh-ident/issues/comments/244018092","html_url":"https://github.com/ccontavalli/ssh-ident/issues/32#issuecomment-244018092","issue_url":"https://api.github.com/repos/ccontavalli/ssh-ident/issues/32","id":244018092,"user":{"login":"mhoff","id":9436725,"avatar_url":"https://avatars.githubusercontent.com/u/9436725?v=3","gravatar_id":"","url":"https://api.github.com/users/mhoff","html_url":"https://github.com/mhoff","followers_url":"https://api.github.com/users/mhoff/followers","following_url":"https://api.github.com/users/mhoff/following{/other_user}","gists_url":"https://api.github.com/users/mhoff/gists{/gist_id}","starred_url":"https://api.github.com/users/mhoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhoff/subscriptions","organizations_url":"https://api.github.com/users/mhoff/orgs","repos_url":"https://api.github.com/users/mhoff/repos","events_url":"https://api.github.com/users/mhoff/events{/privacy}","received_events_url":"https://api.github.com/users/mhoff/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T08:56:26Z","updated_at":"2016-09-01T08:56:26Z","body":"I have further tracked down the issue.\r\n`rsync $REMOTE_HOST:/ .` fails to prompt for the passphrase with `MATCH_ARGV = [... (r\"$REMOTE_HOST\", \"v4\") ...]` being configured.\r\n\r\nI modified `ssh-ident` to print `argv` supplied to `main` when being called.\r\n`/home/mhoff/.bin/ssh $REMOTE_HOST rsync --server --sender -e.Lsfx . /` is able to prompt for the passphrase correctly.\r\nConsequently, something in between `rsync` and the call to `ssh` leads to the above problem.\r\n\r\nI checked the environment being called in (`os.environ`), but the only difference between both calls is that the executed binary differs (`/usr/bin/rsync` versus the path to my test script).\r\n\r\nI really don't know how to proceed from here. I even checked whether `SSH_ASKPASS` is set before calling the evil `subprocess.Popen` but found nothing."}}
{"actor":{"display_login":"mhoff"}}