Skip to content

Instantly share code, notes, and snippets.

@DanyWallace
Created October 27, 2023 22:17
Show Gist options
  • Save DanyWallace/f2e1ef30c174bdf8e6d1ca51c264e7ac to your computer and use it in GitHub Desktop.
Save DanyWallace/f2e1ef30c174bdf8e6d1ca51c264e7ac to your computer and use it in GitHub Desktop.
add the current ssh-agent to your session
# 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