{"id":4213,"date":"2021-06-25T07:13:18","date_gmt":"2021-06-24T22:13:18","guid":{"rendered":"https:\/\/ecpplus.net\/weblog\/?p=4213"},"modified":"2021-06-24T15:36:06","modified_gmt":"2021-06-24T06:36:06","slug":"difference-of-ssh-agent","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/difference-of-ssh-agent\/","title":{"rendered":"Linux \u3068 Mac \u3067\u306f ssh-agent \u306e\u6319\u52d5\u304c\u7570\u306a\u308b"},"content":{"rendered":"<p>SSH\u3057\u305f\u5148\u306e\u30b5\u30fc\u30d0\u3067\u3082\u3001\u624b\u5143\u306e ssh \u306e\u8a8d\u8a3c\u60c5\u5831\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u3001 ssh-agent \u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u6709\u7528\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30d1\u30d6\u30ea\u30c3\u30afIP\u30a2\u30c9\u30ec\u30b9\u3092\u6301\u305f\u306a\u3044\u88cf\u5074\u306b\u3044\u308b\u30b5\u30fc\u30d0\u306b\u3001\u4e00\u65e6\u5225\u30b5\u30fc\u30d0\u3092\u7d4c\u7531\u3057\u3066\u304b\u3089 ssh \u3059\u308b\u5834\u5408<\/li>\n<li>ssh \u3057\u305f\u30b5\u30fc\u30d0\u3067\u3001 ssh \u3092\u4f7f\u3063\u305f <code>git clone<\/code> \u3092\u3057\u305f\u3044\u5834\u5408<\/li>\n<\/ul>\n<h2>\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<h3>Linux \u306e\u5834\u5408<\/h3>\n<pre><code class=\"language-bash\">\u276f eval `ssh-agent -s`\n\u276f ssh-add ~\/path\/to\/key<\/code><\/pre>\n<p>\u3068\u3057\u3066\u3001\u540c\u3058\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u540c\u3058\u30bb\u30c3\u30b7\u30e7\u30f3\u5185\u306e\u307f\u3067\u3001 <code>ssh -A user@host<\/code> \u3067\u9375\u8ee2\u9001\u304c\u884c\u3048\u308b\u3002<code>ssh-agent<\/code> \u306e\u6a19\u6e96\u51fa\u529b\u3092 eval \u3059\u308b\u3053\u3068\u304c\u5fc5\u8981\u3002<\/p>\n<h3>Mac \u306e\u5834\u5408<\/h3>\n<pre><code class=\"language-bash\">\u276f ssh-agent\n\u276f ssh-add ~\/path\/to\/key<\/code><\/pre>\n<p>\u3068\u3059\u308b\u3068\u3001\u5225\u306e\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u958b\u3044\u3066\u3082 <code>ssh -A user@host<\/code> \u3068\u3057\u3066\u9375\u8ee2\u9001\u304c\u884c\u308f\u308c\u3066 ssh \u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002Linux \u3068\u9055\u3063\u3066 eval \u306f\u4e0d\u8981\u3002<\/p>\n<h2>\u4f55\u304c\u9055\u3046\u306e\u304b\uff1f<\/h2>\n<p><code>ssh -A<\/code> \u3057\u305f\u3068\u304d\u3001\u74b0\u5883\u5909\u6570\u306e <code>SSH_AUTH_SOCK<\/code> \u306b\u5165\u3063\u3066\u3044\u308bUNIX\u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8\u3092\u898b\u3066\u3001\u9375\u60c5\u5831\u306e\u8ee2\u9001\u304c\u884c\u308f\u308c\u307e\u3059\u3002\u3082\u3057\u305d\u306e\u74b0\u5883\u5909\u6570\u306b\u5024\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u3068\u8ee2\u9001\u306f\u884c\u308f\u308c\u307e\u305b\u3093\u3002<\/p>\n<p><code>ssh-agent<\/code> \u81ea\u4f53\u306f\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u52d5\u4f5c\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u3067\u3001 <code>SSH_AUTH_SOCK<\/code> \u306e\u30bd\u30b1\u30c3\u30c8\u7d4c\u7531\u3067\u30c7\u30fc\u30bf\u3092\u3084\u308a\u53d6\u308a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><code>ssh-agent<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u51fa\u529b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">\u276f ssh-agent\nSSH_AUTH_SOCK=\/tmp\/ssh-XXXXXXXXXXX\/agent.1234; export SSH_AUTH_SOCK;\nSSH_AGENT_PID=1234; export SSH_AGENT_PID;\necho Agent pid 1234;<\/code><\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001 <code>SSH_AUTH_SOCK<\/code> \u3068 <code>SSH_AGENT_PID<\/code> \u304c\u74b0\u5883\u5909\u6570\u306b\u30bb\u30c3\u30c8\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u72b6\u614b\u3067 <code>ssh-add<\/code> \u3084 <code>ssh -A<\/code> \u3092\u884c\u3046\u3068\u3001 <code>SSH_AUTH_SOCK<\/code> \u304c\u3069\u3053\u306b\u3042\u308b\u304b\u5206\u304b\u308b\u306e\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f Mac \u3067\u3082 Linux \u3067\u3082\u540c\u3058\u3088\u3046\u306a\u6a19\u6e96\u51fa\u529b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001Mac \u306e\u5834\u5408\u306f\u306a\u305c\u304b\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u5225\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3067\u3082 <code>ssh-add<\/code> \u3084 <code>ssh -A<\/code> \u304c\u5b9f\u884c\u3067\u304d\u3066\u3044\u307e\u3059\u3002\u4f55\u6545\u306a\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<h3>SSH_AUTH_SOCK \u306e\u6271\u3044<\/h3>\n<p>Mac \u3067\u306f\u3001 <code>echo $SSH_AUTH_SOCK<\/code> \u3059\u308b\u3068\u3001<code>\/private\/tmp\/com.cpple.launchd.XXXXXXXX\/Listeners<\/code> \u3068\u3044\u3046\u6587\u5b57\u5217\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><code>ssh-agent<\/code> \u306e\u30bd\u30b1\u30c3\u30c8\u306f\u3053\u3053\u3067 Listen \u3057\u3066 <code>ssh-agent<\/code> \u306e\u30d7\u30ed\u30bb\u30b9\u306b\u6e21\u3059\u3068\u3044\u3046\u3053\u3068\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u305f\u3081\u3001<code>$SSH_AUTH_SOCK<\/code> \u304c\u3069\u3053\u304b\u3089\u3067\u3082\u898b\u3048\u3066\u900f\u904e\u7684\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u9006\u306b\u8907\u6570\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3067 <code>ssh-agent<\/code> \u3092\u3057\u3066\u3082\u3001 <code>$SSH_AUTH_SOCK<\/code> \u306f\u305d\u306e\u3046\u3061\u306e1\u3064\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001 <code>ssh-agent<\/code> \u306e\u30d7\u30ed\u30bb\u30b9\u81ea\u4f53\u306f\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u56de\u6570\u5206\u3060\u3051\u8d77\u52d5\u3057\u3066\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>Linux \u306e\u6319\u52d5\u304c\u826f\u3044\u304b\u3001Mac \u306e\u6319\u52d5\u304c\u826f\u3044\u304b\u3001\u306f\u4e00\u9577\u4e00\u77ed\u3068\u3044\u3046\u611f\u3058\u306b\u898b\u3048\u307e\u3059\ud83d\ude42<\/p>\n<p>\u3044\u305a\u308c\u306b\u3057\u3066\u3082\u3001 <code>ssh-agent<\/code> \u304c\u5fc5\u8981\u306a\u4f5c\u696d\u304c\u7d42\u308f\u3063\u305f\u3089 <code>killall ssh-agent<\/code> \u3067\u30d7\u30ed\u30bb\u30b9\u3092\u7d42\u4e86\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"language-bash\">\u276f killall ssh-agent<\/code><\/pre>\n<h3>Linux \u3067\u3082 Mac \u306e\u3088\u3046\u306a\u6319\u52d5\u306b\u3059\u308b\u306a\u3089<\/h3>\n<p>\u30bd\u30b1\u30c3\u30c8\u306e\u30d1\u30b9\u3092\u56fa\u5b9a\u3059\u308c\u3070\u540c\u3058\u6319\u52d5\u306b\u3059\u308b\u3053\u3068\u3082\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u30b7\u30a7\u30eb\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u7b49 (<code>.zshenv<\/code> \u7b49) \u3067\u3001<code>SSH_AUTH_SOCK<\/code> \u3092\u56fa\u5b9a\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<pre><code>export SSH_AUTH_SOCK=\/tmp\/ssh-agent.sock<\/code><\/pre>\n<p><code>ssh-agent<\/code> \u8d77\u52d5\u6642\u306b\u30bd\u30b1\u30c3\u30c8\u306e\u30d1\u30b9\u3092\u6e21\u305b\u308b\u306e\u3067\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3057\u3066\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code>\u276f ssh-agent -a $SSH_AUTH_SOCK<\/code><\/pre>\n<p>\u3042\u3068\u306f\u3001\u4ed6\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3067\u3082 <code>$SSH_AUTH_SOCK<\/code> \u304c\u56fa\u5b9a\u3055\u308c\u3066\u3044\u308b\u306e\u3067 Mac \u306e\u3088\u3046\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001 <code>ssh-add<\/code> \u3057\u305f\u9375\u304c\u5168\u90e8\u8ee2\u9001\u3055\u308c\u305f\u308a\u30c7\u30e1\u30ea\u30c3\u30c8\u3082\u3042\u308b\u306e\u3067\u3001\u50d5\u306f\u5192\u982d\u306b\u66f8\u3044\u305f\u3088\u3046\u306b <code>eval<\/code> \u3057\u3066\u305d\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u5185\u306e\u307f\u3067\u4f7f\u3046\u3088\u3046\u306a\u904b\u7528\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u597d\u307f\u306e\u554f\u984c\u3067\u3059\u306d\ud83d\ude43<\/p>\n<hr \/>\n<p>\u521d\u3081\u3066 <code>ssh-agent<\/code> \u3092\u4f7f\u3063\u305f\u306e\u304c Mac \u3060\u3063\u305f\u306e\u3067\u3001WSL2 \u3067\u958b\u767a\u74b0\u5883\u69cb\u7bc9\u3057\u3066\u3044\u305f\u3089\u671f\u5f85\u901a\u308a\u306b\u52d5\u304b\u305a\u306f\u3058\u3081\u56f0\u60d1\u3057\u307e\u3057\u305f\u3002\u7d30\u304b\u3044\u90e8\u5206\u3067\u5dee\u7570\u304c\u3042\u308a\u3001\u306a\u304b\u306a\u304b\u9762\u767d\u3044\u3067\u3059\ud83d\ude0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ssh-agent \u306f\u9375\u8ee2\u9001\u306b\u4fbf\u5229\u3067\u3059\u304c\u3001Linux \u3068 macOS \u3067\u6319\u52d5\u304c\u7570\u306a\u3063\u305f\u306e\u3067\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":3958,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[7,12],"class_list":["post-4213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-linux","tag-mac"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=4213"}],"version-history":[{"count":5,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4213\/revisions"}],"predecessor-version":[{"id":4216,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4213\/revisions\/4216"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/3958"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=4213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=4213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=4213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}