Created
October 19, 2017 06:57
-
-
Save RichardBronosky/514dbbcd20a9ed77661fc3db9d1f93e4 to your computer and use it in GitHub Desktop.
Get a list of private key paths known by the SSH Agent connected to the SSH Auth Socket
This file contains 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
#!/bin/bash | |
function binary_dump_of_keys(){ | |
echo -en '\x00\x00\x00\x01\x0b' | nc -q 1 -U $SSH_AUTH_SOCK | |
} | |
function filter(){ | |
strings | sed '/.ssh/!d; s/^[^/]*//' | |
} | |
binary_dump_of_keys | filter | |
# example output: | |
# /Users/bbronosky/.ssh/id_rsa.pem | |
# /Users/bbronosky/.ssh/root_bootstrap.pem | |
# /Users/bbronosky/.ssh/aws_master.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I leaned heavily on https://ptspts.blogspot.com/2010/06/how-to-use-ssh-agent-programmatically.html for this.