Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. '''
  2. Created on Mar 11, 2015
  3.  
  4. @author: roman
  5. '''
  6.  
  7. import subprocess
  8. import re
  9. import os
  10.  
  11. runme = subprocess.check_output(["ssh-agent"]).decode("utf-8")
  12.  
  13. re_auth_sock = re.compile('SSH_AUTH_SOCK=(?P<SSH_AUTH_SOCK>[^;]*);')
  14. ssh_auth_sock = re.search(re_auth_sock, runme).group("SSH_AUTH_SOCK");
  15.  
  16. re_agent_pid = re.compile('SSH_AGENT_PID=(?P<SSH_AGENT_PID>[^;]*);')
  17. ssh_agent_pid = re.search(re_agent_pid, runme).group("SSH_AGENT_PID");
  18.  
  19. #local for the local call, userspace for further calls from the command line
  20. os.environ['SSH_AUTH_SOCK'] = ssh_auth_sock
  21. os.system("setx SSH_AUTH_SOCK " + ssh_auth_sock)
  22.  
  23. os.environ['SSH_AGENT_PID'] = ssh_agent_pid
  24. os.system("setx SSH_AGENT_PID " + ssh_agent_pid)
  25.  
  26. os.system("ssh-add %USERPROFILE%/.ssh/*_rsa")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement