Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Created on Mar 11, 2015
- @author: roman
- '''
- import subprocess
- import re
- import os
- runme = subprocess.check_output(["ssh-agent"]).decode("utf-8")
- re_auth_sock = re.compile('SSH_AUTH_SOCK=(?P<SSH_AUTH_SOCK>[^;]*);')
- ssh_auth_sock = re.search(re_auth_sock, runme).group("SSH_AUTH_SOCK");
- re_agent_pid = re.compile('SSH_AGENT_PID=(?P<SSH_AGENT_PID>[^;]*);')
- ssh_agent_pid = re.search(re_agent_pid, runme).group("SSH_AGENT_PID");
- #local for the local call, userspace for further calls from the command line
- os.environ['SSH_AUTH_SOCK'] = ssh_auth_sock
- os.system("setx SSH_AUTH_SOCK " + ssh_auth_sock)
- os.environ['SSH_AGENT_PID'] = ssh_agent_pid
- os.system("setx SSH_AGENT_PID " + ssh_agent_pid)
- os.system("ssh-add %USERPROFILE%/.ssh/*_rsa")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement