Skip to content

Instantly share code, notes, and snippets.

@aron-bordin
Created July 7, 2015 00:38
Show Gist options
  • Save aron-bordin/b1bd3f766747aa401413 to your computer and use it in GitHub Desktop.
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
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("git@github.com", _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