Created
July 7, 2015 00:38
-
-
Save aron-bordin/b1bd3f766747aa401413 to your computer and use it in GitHub Desktop.
Validate if git remote(github) password is valid. To do it, I try to connect to the git ssh. It'll run the ssh-agent and start it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sh import ssh, ErrorReturnCode_1, ErrorReturnCode_255 | |
aggregated = "" | |
def ssh_interact(char, stdin): | |
global aggregated | |
aggregated += char | |
if aggregated.startswith("Enter passphrase"): | |
stdin.put("mypass\n") | |
try: | |
p = ssh("[email protected]", _out=ssh_interact, _out_bufsize=0, _tty_in=True) | |
p.wait() | |
except ErrorReturnCode_1: | |
print('Password valid!') | |
except ErrorReturnCode_255: | |
print('Invalid password!!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment