Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Created October 19, 2017 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardBronosky/514dbbcd20a9ed77661fc3db9d1f93e4 to your computer and use it in GitHub Desktop.
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
#!/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
@RichardBronosky
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment