{"action":"created","issue":{"url":"https://api.github.com/repos/paramiko/paramiko/issues/797","repository_url":"https://api.github.com/repos/paramiko/paramiko","labels_url":"https://api.github.com/repos/paramiko/paramiko/issues/797/labels{/name}","comments_url":"https://api.github.com/repos/paramiko/paramiko/issues/797/comments","events_url":"https://api.github.com/repos/paramiko/paramiko/issues/797/events","html_url":"https://github.com/paramiko/paramiko/issues/797","id":170883615,"number":797,"title":"Having issues with paramiko for session that need to be open for long time. ","user":{"login":"arshdeeptinna","id":13384143,"avatar_url":"https://avatars.githubusercontent.com/u/13384143?v=3","gravatar_id":"","url":"https://api.github.com/users/arshdeeptinna","html_url":"https://github.com/arshdeeptinna","followers_url":"https://api.github.com/users/arshdeeptinna/followers","following_url":"https://api.github.com/users/arshdeeptinna/following{/other_user}","gists_url":"https://api.github.com/users/arshdeeptinna/gists{/gist_id}","starred_url":"https://api.github.com/users/arshdeeptinna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arshdeeptinna/subscriptions","organizations_url":"https://api.github.com/users/arshdeeptinna/orgs","repos_url":"https://api.github.com/users/arshdeeptinna/repos","events_url":"https://api.github.com/users/arshdeeptinna/events{/privacy}","received_events_url":"https://api.github.com/users/arshdeeptinna/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/paramiko/paramiko/labels/Needs%20investigation","name":"Needs investigation","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-12T14:28:26Z","updated_at":"2016-08-13T15:43:38Z","closed_at":null,"body":"So I have a script where I need to connect to a few nodes sequentially to run a bunch commands that can take a few hours to complete. For each node I do something like following\r\n\r\n```\r\nfor node in nodes:\r\n    tunnel = spur.SshShell(hostname=node, username='xyz')\r\n    with tunnel:\r\n        for cmd in cmds:\r\n            result = tunnel.run(cmd)\r\n           do_something()\r\n```\r\nI run the above script in a screen session. The issue I am seeing is that all commands are run succesfully for first node but after that following exception is raised\r\n\r\n```\r\nOriginal error: No authentication methods available\r\nTraceback (most recent call last):\r\n  File \"xyz.py\", line 219, in <module>\r\n    main()\r\n  File \"xyz.py\", line 55, in __init__\r\n    self.nodes = self.get_nodes_info()\r\n  File xyz, line 63, in get_nodes_info\r\n    tunnel = ssh_tunnel(str(self.seed_ip))\r\n  File \"xyy\", line 29, in ssh_tunnel\r\n    tunnel.run([\"uptime\"])\r\n  File \"/usr/local/lib/python2.7/dist-packages/spur/ssh.py\", line 162, in run\r\n    return self.spawn(*args, **kwargs).wait_for_result()\r\n  File \"/usr/local/lib/python2.7/dist-packages/spur/ssh.py\", line 173, in spawn\r\n    channel = self._get_ssh_transport().open_session()\r\n  File \"/usr/local/lib/python2.7/dist-packages/spur/ssh.py\", line 251, in _get_ssh_transport\r\n    raise self._connection_error(error)\r\nspur.ssh.ConnectionError: Error creating SSH connection\r\nOriginal error: No authentication methods available\r\n```\r\n\r\nI also noticed that in this same screen session I can not use spur at all. Even in python interpreter keep on hitting the same error. However I can connect to the same node in a different screen session. It seems like  the fact that commands take a long time to complete and thus need to keep session active for a long time messes up spur or paramiko.\r\n\r\nAnother scenario that I tried was to open a different screen session and replaced the commands that I need to run with simpler bash commands. In this case the commands were executed on all nodes without any issues.  \r\n"},"comment":{"url":"https://api.github.com/repos/paramiko/paramiko/issues/comments/239627105","html_url":"https://github.com/paramiko/paramiko/issues/797#issuecomment-239627105","issue_url":"https://api.github.com/repos/paramiko/paramiko/issues/797","id":239627105,"user":{"login":"bitprophet","id":6088,"avatar_url":"https://avatars.githubusercontent.com/u/6088?v=3","gravatar_id":"","url":"https://api.github.com/users/bitprophet","html_url":"https://github.com/bitprophet","followers_url":"https://api.github.com/users/bitprophet/followers","following_url":"https://api.github.com/users/bitprophet/following{/other_user}","gists_url":"https://api.github.com/users/bitprophet/gists{/gist_id}","starred_url":"https://api.github.com/users/bitprophet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitprophet/subscriptions","organizations_url":"https://api.github.com/users/bitprophet/orgs","repos_url":"https://api.github.com/users/bitprophet/repos","events_url":"https://api.github.com/users/bitprophet/events{/privacy}","received_events_url":"https://api.github.com/users/bitprophet/received_events","type":"User","site_admin":false},"created_at":"2016-08-13T15:43:37Z","updated_at":"2016-08-13T15:43:37Z","body":"Oh, I see what you mean now. That's really interesting, I don't think I've seen that sort of thing before.\r\n\r\nNot familiar with `spur` but I can't see offhand why Paramiko would have a problem there unless the long-lived screen session itself is generating environmental limitations, e.g. running afoul of ulimits or something like that. Certainly anything that causes errors which *span* multiple Python interpreter sessions seems like it'd have to be environmental in origin if it's not 100% so.\r\n\r\nIf you post the raw-Paramiko-no-Spur code snippet that might also give us a clue. If it's tunnel related, and something in your screen/shell is e.g. preventing properly spawning or piping to `ProxyCommand` related subprocesses, that can cause all kinds of strange behaviors at the \"inner connection\" level (i.e. the connection trying to use the tunnel socket)."}}
{"actor":{"display_login":"bitprophet"}}