Created
October 27, 2023 22:17
-
-
Save DanyWallace/f2e1ef30c174bdf8e6d1ca51c264e7ac to your computer and use it in GitHub Desktop.
add the current ssh-agent to your session
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
# run on your wsl shell: | |
# eval `ruby file.rb` | |
def get_agent | |
ps_aux_output = `ps aux | grep ssh-agent` | |
agent_pid = ps_aux_output.split("\n")[0] | |
agent_pid = agent_pid.match(/\d+/)[0].to_i - 1 | |
ssh_auth_sock = `find /tmp/ssh-*/ -type s -name agent.#{agent_pid}` | |
print "export SSH_AUTH_SOCK=#{ssh_auth_sock}" | |
end | |
if ARGV[0] == 'help' | |
puts "execute in your terminal: eval `ruby ssh-utils.rb`" | |
else | |
get_agent | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment