{"action":"created","comment":{"url":"https://api.github.com/repos/cloudflare/redoctober/pulls/comments/47393285","id":47393285,"diff_hunk":"@@ -0,0 +1,122 @@\n+// Package roagent provides ROAgent, which implements the SSH agent interface,\n+// forwarding sign requests to a Red October server\n+package roagent\n+\n+import (\n+\t\"bytes\"\n+\t\"crypto/rand\"\n+\t\"encoding/json\"\n+\t\"errors\"\n+\t\"io\"\n+\t\"log\"\n+\n+\t\"github.com/cloudflare/redoctober/client\"\n+\t\"github.com/cloudflare/redoctober/core\"\n+\t\"golang.org/x/crypto/ssh\"\n+\t\"golang.org/x/crypto/ssh/agent\"\n+)\n+\n+type ROSigner struct {\n+\tserver       *client.RemoteServer\n+\tpub          ssh.PublicKey\n+\tencryptedKey []byte\n+\tuser         string\n+\tpswd         string\n+}\n+\n+func (signer ROSigner) PublicKey() ssh.PublicKey {\n+\treturn signer.pub\n+}\n+\n+func (signer ROSigner) Sign(rand io.Reader, msg []byte) (signature *ssh.Signature, err error) {\n+\treq := core.SSHSignWithRequest{\n+\t\tName:     signer.user,\n+\t\tPassword: signer.pswd,\n+\t\tData:     signer.encryptedKey,\n+\t\tTBSData:  msg,\n+\t}\n+\n+\tresp, err := signer.server.SSHSignWith(req)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tif resp.Status != \"ok\" {\n+\t\tlog.Fatal(\"response status error:\", resp.Status)","path":"cmd/ro/roagent/roagent.go","position":44,"original_position":44,"commit_id":"3901f250cd509756ab3e9fbddc06581da6f8dca6","original_commit_id":"a778b667480774880402c20f44ee89b63c594f46","user":{"login":"j-delaney","id":3589480,"avatar_url":"https://avatars.githubusercontent.com/u/3589480?v=3","gravatar_id":"","url":"https://api.github.com/users/j-delaney","html_url":"https://github.com/j-delaney","followers_url":"https://api.github.com/users/j-delaney/followers","following_url":"https://api.github.com/users/j-delaney/following{/other_user}","gists_url":"https://api.github.com/users/j-delaney/gists{/gist_id}","starred_url":"https://api.github.com/users/j-delaney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j-delaney/subscriptions","organizations_url":"https://api.github.com/users/j-delaney/orgs","repos_url":"https://api.github.com/users/j-delaney/repos","events_url":"https://api.github.com/users/j-delaney/events{/privacy}","received_events_url":"https://api.github.com/users/j-delaney/received_events","type":"User","site_admin":false},"body":"That's because GitHub does \"outdated\" by whether the line being commented on has changed, not the file itself.","created_at":"2015-12-11T19:22:09Z","updated_at":"2015-12-11T19:22:09Z","html_url":"https://github.com/cloudflare/redoctober/pull/105#discussion_r47393285","pull_request_url":"https://api.github.com/repos/cloudflare/redoctober/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/cloudflare/redoctober/pulls/comments/47393285"},"html":{"href":"https://github.com/cloudflare/redoctober/pull/105#discussion_r47393285"},"pull_request":{"href":"https://api.github.com/repos/cloudflare/redoctober/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/cloudflare/redoctober/pulls/105","id":52128886,"html_url":"https://github.com/cloudflare/redoctober/pull/105","diff_url":"https://github.com/cloudflare/redoctober/pull/105.diff","patch_url":"https://github.com/cloudflare/redoctober/pull/105.patch","issue_url":"https://api.github.com/repos/cloudflare/redoctober/issues/105","number":105,"state":"open","locked":false,"title":"SSH integration","user":{"login":"andrewbuss","id":5904167,"avatar_url":"https://avatars.githubusercontent.com/u/5904167?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewbuss","html_url":"https://github.com/andrewbuss","followers_url":"https://api.github.com/users/andrewbuss/followers","following_url":"https://api.github.com/users/andrewbuss/following{/other_user}","gists_url":"https://api.github.com/users/andrewbuss/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewbuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewbuss/subscriptions","organizations_url":"https://api.github.com/users/andrewbuss/orgs","repos_url":"https://api.github.com/users/andrewbuss/repos","events_url":"https://api.github.com/users/andrewbuss/events{/privacy}","received_events_url":"https://api.github.com/users/andrewbuss/received_events","type":"User","site_admin":false},"body":"The first commit adds an API endpoint to Red October which decrypts an SSH key and uses it to sign a message. \r\n\r\nThe later commit uses this endpoint to implement a remote signer which is used in a minimal SSH agent implementation. The goal is to be able to use an unmodified SSH client. When the SSH client tries to authenticate to a remote server, the server asks the client to sign a message with its key to set up the session. The client here forwards the message to our custom agent, which in turn passes it to the RO server, which signs the message if all necessary delegations are available. The signature is passed back along to the server through the agent and SSH client. \r\n\r\nThe agent needs to know which public key corresponds to the encrypted private key, so there is a -pubkey command line flag which accepts the path to the appropriate pubkey file. \r\n\r\nThe third commit adds an optional Usages field to the EncryptedData struct. A user can specify on encryption that an encrypted file may only be used as an SSH signer, and may not be directly decrypted to return a private key. If Usages is missing or empty, decryption is permitted.\r\n\r\nExample:\r\n\r\n`ro -in id_rsa.encrypted -server redoctob.er:8080 -pubkey id_rsa.pub ssh root@server`","created_at":"2015-11-30T14:17:42Z","updated_at":"2015-12-11T19:22:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7af992dc4f3fdbfd7cdadf6a842e7280d245d919","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudflare/redoctober/pulls/105/commits","review_comments_url":"https://api.github.com/repos/cloudflare/redoctober/pulls/105/comments","review_comment_url":"https://api.github.com/repos/cloudflare/redoctober/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudflare/redoctober/issues/105/comments","statuses_url":"https://api.github.com/repos/cloudflare/redoctober/statuses/3901f250cd509756ab3e9fbddc06581da6f8dca6","head":{"label":"andrewbuss:decrypt_sign","ref":"decrypt_sign","sha":"3901f250cd509756ab3e9fbddc06581da6f8dca6","user":{"login":"andrewbuss","id":5904167,"avatar_url":"https://avatars.githubusercontent.com/u/5904167?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewbuss","html_url":"https://github.com/andrewbuss","followers_url":"https://api.github.com/users/andrewbuss/followers","following_url":"https://api.github.com/users/andrewbuss/following{/other_user}","gists_url":"https://api.github.com/users/andrewbuss/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewbuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewbuss/subscriptions","organizations_url":"https://api.github.com/users/andrewbuss/orgs","repos_url":"https://api.github.com/users/andrewbuss/repos","events_url":"https://api.github.com/users/andrewbuss/events{/privacy}","received_events_url":"https://api.github.com/users/andrewbuss/received_events","type":"User","site_admin":false},"repo":{"id":43838393,"name":"redoctober","full_name":"andrewbuss/redoctober","owner":{"login":"andrewbuss","id":5904167,"avatar_url":"https://avatars.githubusercontent.com/u/5904167?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewbuss","html_url":"https://github.com/andrewbuss","followers_url":"https://api.github.com/users/andrewbuss/followers","following_url":"https://api.github.com/users/andrewbuss/following{/other_user}","gists_url":"https://api.github.com/users/andrewbuss/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewbuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewbuss/subscriptions","organizations_url":"https://api.github.com/users/andrewbuss/orgs","repos_url":"https://api.github.com/users/andrewbuss/repos","events_url":"https://api.github.com/users/andrewbuss/events{/privacy}","received_events_url":"https://api.github.com/users/andrewbuss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewbuss/redoctober","description":"Go server for two-man rule style file encryption and decryption.","fork":true,"url":"https://api.github.com/repos/andrewbuss/redoctober","forks_url":"https://api.github.com/repos/andrewbuss/redoctober/forks","keys_url":"https://api.github.com/repos/andrewbuss/redoctober/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewbuss/redoctober/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewbuss/redoctober/teams","hooks_url":"https://api.github.com/repos/andrewbuss/redoctober/hooks","issue_events_url":"https://api.github.com/repos/andrewbuss/redoctober/issues/events{/number}","events_url":"https://api.github.com/repos/andrewbuss/redoctober/events","assignees_url":"https://api.github.com/repos/andrewbuss/redoctober/assignees{/user}","branches_url":"https://api.github.com/repos/andrewbuss/redoctober/branches{/branch}","tags_url":"https://api.github.com/repos/andrewbuss/redoctober/tags","blobs_url":"https://api.github.com/repos/andrewbuss/redoctober/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewbuss/redoctober/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewbuss/redoctober/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewbuss/redoctober/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewbuss/redoctober/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewbuss/redoctober/languages","stargazers_url":"https://api.github.com/repos/andrewbuss/redoctober/stargazers","contributors_url":"https://api.github.com/repos/andrewbuss/redoctober/contributors","subscribers_url":"https://api.github.com/repos/andrewbuss/redoctober/subscribers","subscription_url":"https://api.github.com/repos/andrewbuss/redoctober/subscription","commits_url":"https://api.github.com/repos/andrewbuss/redoctober/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewbuss/redoctober/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewbuss/redoctober/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewbuss/redoctober/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrewbuss/redoctober/contents/{+path}","compare_url":"https://api.github.com/repos/andrewbuss/redoctober/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewbuss/redoctober/merges","archive_url":"https://api.github.com/repos/andrewbuss/redoctober/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewbuss/redoctober/downloads","issues_url":"https://api.github.com/repos/andrewbuss/redoctober/issues{/number}","pulls_url":"https://api.github.com/repos/andrewbuss/redoctober/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewbuss/redoctober/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewbuss/redoctober/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewbuss/redoctober/labels{/name}","releases_url":"https://api.github.com/repos/andrewbuss/redoctober/releases{/id}","created_at":"2015-10-07T19:02:19Z","updated_at":"2015-10-07T19:02:19Z","pushed_at":"2015-12-10T08:48:27Z","git_url":"git://github.com/andrewbuss/redoctober.git","ssh_url":"git@github.com:andrewbuss/redoctober.git","clone_url":"https://github.com/andrewbuss/redoctober.git","svn_url":"https://github.com/andrewbuss/redoctober","homepage":"http://blog.cloudflare.com/red-october-cloudflares-open-source-implementation-of-the-two-man-rule","size":329,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cloudflare:master","ref":"master","sha":"1bfa291c370c137cee14ddee7029554ae0d4fc88","user":{"login":"cloudflare","id":314135,"avatar_url":"https://avatars.githubusercontent.com/u/314135?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudflare","html_url":"https://github.com/cloudflare","followers_url":"https://api.github.com/users/cloudflare/followers","following_url":"https://api.github.com/users/cloudflare/following{/other_user}","gists_url":"https://api.github.com/users/cloudflare/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudflare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudflare/subscriptions","organizations_url":"https://api.github.com/users/cloudflare/orgs","repos_url":"https://api.github.com/users/cloudflare/repos","events_url":"https://api.github.com/users/cloudflare/events{/privacy}","received_events_url":"https://api.github.com/users/cloudflare/received_events","type":"Organization","site_admin":false},"repo":{"id":14510383,"name":"redoctober","full_name":"cloudflare/redoctober","owner":{"login":"cloudflare","id":314135,"avatar_url":"https://avatars.githubusercontent.com/u/314135?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudflare","html_url":"https://github.com/cloudflare","followers_url":"https://api.github.com/users/cloudflare/followers","following_url":"https://api.github.com/users/cloudflare/following{/other_user}","gists_url":"https://api.github.com/users/cloudflare/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudflare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudflare/subscriptions","organizations_url":"https://api.github.com/users/cloudflare/orgs","repos_url":"https://api.github.com/users/cloudflare/repos","events_url":"https://api.github.com/users/cloudflare/events{/privacy}","received_events_url":"https://api.github.com/users/cloudflare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudflare/redoctober","description":"Go server for two-man rule style file encryption and decryption.","fork":false,"url":"https://api.github.com/repos/cloudflare/redoctober","forks_url":"https://api.github.com/repos/cloudflare/redoctober/forks","keys_url":"https://api.github.com/repos/cloudflare/redoctober/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudflare/redoctober/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudflare/redoctober/teams","hooks_url":"https://api.github.com/repos/cloudflare/redoctober/hooks","issue_events_url":"https://api.github.com/repos/cloudflare/redoctober/issues/events{/number}","events_url":"https://api.github.com/repos/cloudflare/redoctober/events","assignees_url":"https://api.github.com/repos/cloudflare/redoctober/assignees{/user}","branches_url":"https://api.github.com/repos/cloudflare/redoctober/branches{/branch}","tags_url":"https://api.github.com/repos/cloudflare/redoctober/tags","blobs_url":"https://api.github.com/repos/cloudflare/redoctober/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudflare/redoctober/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudflare/redoctober/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudflare/redoctober/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudflare/redoctober/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudflare/redoctober/languages","stargazers_url":"https://api.github.com/repos/cloudflare/redoctober/stargazers","contributors_url":"https://api.github.com/repos/cloudflare/redoctober/contributors","subscribers_url":"https://api.github.com/repos/cloudflare/redoctober/subscribers","subscription_url":"https://api.github.com/repos/cloudflare/redoctober/subscription","commits_url":"https://api.github.com/repos/cloudflare/redoctober/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudflare/redoctober/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudflare/redoctober/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudflare/redoctober/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudflare/redoctober/contents/{+path}","compare_url":"https://api.github.com/repos/cloudflare/redoctober/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudflare/redoctober/merges","archive_url":"https://api.github.com/repos/cloudflare/redoctober/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudflare/redoctober/downloads","issues_url":"https://api.github.com/repos/cloudflare/redoctober/issues{/number}","pulls_url":"https://api.github.com/repos/cloudflare/redoctober/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudflare/redoctober/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudflare/redoctober/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudflare/redoctober/labels{/name}","releases_url":"https://api.github.com/repos/cloudflare/redoctober/releases{/id}","created_at":"2013-11-19T01:15:58Z","updated_at":"2015-12-10T16:30:50Z","pushed_at":"2015-12-10T08:48:27Z","git_url":"git://github.com/cloudflare/redoctober.git","ssh_url":"git@github.com:cloudflare/redoctober.git","clone_url":"https://github.com/cloudflare/redoctober.git","svn_url":"https://github.com/cloudflare/redoctober","homepage":"http://blog.cloudflare.com/red-october-cloudflares-open-source-implementation-of-the-two-man-rule","size":541,"stargazers_count":909,"watchers_count":909,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":13,"forks":75,"open_issues":13,"watchers":909,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudflare/redoctober/pulls/105"},"html":{"href":"https://github.com/cloudflare/redoctober/pull/105"},"issue":{"href":"https://api.github.com/repos/cloudflare/redoctober/issues/105"},"comments":{"href":"https://api.github.com/repos/cloudflare/redoctober/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudflare/redoctober/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudflare/redoctober/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudflare/redoctober/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/cloudflare/redoctober/statuses/3901f250cd509756ab3e9fbddc06581da6f8dca6"}}}}