{"id":5233,"date":"2017-02-08T00:01:45","date_gmt":"2017-02-07T15:01:45","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=5233"},"modified":"2017-02-08T12:55:48","modified_gmt":"2017-02-08T03:55:48","slug":"ssh_wrapper","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/ssh_wrapper.html","title":{"rendered":"\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u306e\u30b5\u30fc\u30d0\u3067\u30b3\u30de\u30f3\u30c9\u3092\u305d\u306e\u307e\u307e\u5b9f\u884c\u3055\u305b\u308bSSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9 \uff5e\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u8907\u6570\u306e\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u3078\u4e26\u5217\u51e6\u7406\u3092\u53ef\u80fd\u306b\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\uff5e"},"content":{"rendered":"

\u6700\u8fd1\u3067\u306f\u30d1\u30d6\u30ea\u30c3\u30af\u30af\u30e9\u30a6\u30c9\u304c\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3092\u4ecb\u3057\u3066\u30af\u30e9\u30a6\u30c9\u4e0a\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u969b\u306b\u306fSSH\u3092\u5fc5\u305a\u3068\u8a00\u3063\u3066\u3044\u3044\u307b\u3069\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n

SSH\u306f\u516c\u958b\u9375\u8a8d\u8a3c\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u901a\u4fe1\u3082\u6697\u53f7\u5316\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30ed\u30b0\u30a4\u30f3\u4ee5\u5916\u306b\u3082\u30af\u30e9\u30a6\u30c9\u30e9\u30a4\u30af\u306a\u30b5\u30fc\u30d0\u30fc\u9593\u9023\u643a\u306b\u3082\u5229\u7528\u3055\u308c\u308b\u306a\u3069\u5fc5\u8981\u4e0d\u53ef\u6b20\u306a\u30d7\u30ed\u30c8\u30b3\u30eb\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306fSSH\u3092\u7528\u3044\u305f\u30b5\u30fc\u30d0\u9593\u9023\u643a\u3092\u5bb9\u6613\u306b\u3057\u3001\u30b5\u30fc\u30d0\u3054\u3068\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7528\u610f\u3059\u308b\u3053\u3068\u3067\u8907\u6570\u30b5\u30fc\u30d0\u306b\u5bfe\u3057\u3066\u4e26\u5217\u51e6\u7406\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3067\u304d\u308bSSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9\u306e\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n

\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u306e\u30b5\u30fc\u30d0\u3067\u30b3\u30de\u30f3\u30c9\u3092\u305d\u306e\u307e\u307e\u5b9f\u884c\u3055\u305b\u308bSSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9 \uff5e\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u8907\u6570\u306e\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u3078\u4e26\u5217\u51e6\u7406\u3092\u53ef\u80fd\u306b\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\uff5e<\/h2>\n

\u4e0b\u8a18\u306b\u8a18\u8f09\u3057\u3066\u3042\u308b\u5185\u5bb9\u3067SSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9\u3092\u5404\u30b5\u30fc\u30d0\u6bce\u306b\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u5b9f\u884c\u5143\u306e\u30b5\u30fc\u30d0\u306e\u30ed\u30fc\u30ab\u30eb\u306b\u3044\u306a\u304c\u3089\u306b\u3057\u3066\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u3078SSH\u7d4c\u7531\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

\u3053\u306eSSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u8907\u6570\u306e\u30b5\u30fc\u30d0\u306b\u4efb\u610f\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067SSH\u7d4c\u7531\u306e\u4e26\u5217\u51e6\u7406\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u306e\u30b5\u30fc\u30d0\u3067\u30b3\u30de\u30f3\u30c9\u3092\u305d\u306e\u307e\u307e\u5b9f\u884c\u3055\u305b\u308bSSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9<\/h3>\n

\u4eca\u56de\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u901a\u4fe1\u901f\u5ea6\u3088\u308a\u3082\u901a\u4fe1\u91cf\u3092\u8003\u616e\u3057\u3066ssh\u30b3\u30de\u30f3\u30c9\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u300c-C -o CompressionLevel=9\u300d\u3067\u5168\u3066\u306e\u30c7\u30fc\u30bf\u306e\u5727\u7e2e\u3092\u30ec\u30d9\u30eb9(\u6700\u9ad8\u5727\u7e2e)\u3067\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u300c-i ~\/.ssh\/private_key.pem\u300d\u306e\u90e8\u5206\u306f\u516c\u958b\u9375\u8a8d\u8a3c\u306e\u79d8\u5bc6\u9375\u306e\u30d1\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u300cmagtranetwork@magtranetwork.com\u300d\u306e\u90e8\u5206\u306f\u30ed\u30b0\u30a4\u30f3\u5bfe\u8c61\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u30db\u30b9\u30c8\u540d\u3067\u3059\u3002<\/p>\n

\u300c”export PATH=[\u5b9f\u884c\u6642\u306b\u901a\u3059\u30d1\u30b9] && $*”\u300d\u3068\u3059\u308b\u3053\u3068\u3067\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u3067\u5b9f\u884c\u3059\u308b\u969b\u306e\u30d1\u30b9\u3092\u8a2d\u5b9a\u3057\u3066\u3001\u5f8c\u7d9a\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306f\u4ee5\u524d\u306e\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u305fpyenv, rbenv, ndenv\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fpython, ruby, node\u3092\u4f7f\u3048\u308b\u3088\u3046\u306a\u30d1\u30b9\u8a2d\u5b9a\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u53c2\u8003\u8a18\u4e8b\uff1a\u300cpyenv\u3001rbenv\u3001ndenv\u3092\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u30fb\u30b7\u30b9\u30c6\u30e0\u30ef\u30a4\u30c9\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001Python\u3001Ruby\u3001Node.js\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u4f7f\u3044\u5206\u3051\u308b \u301cAmazon Linux\u3001CentOS\u3067\u5b9f\u884c\u3067\u304d\u308b\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u301c<\/a>\u300d<\/p>\n

\u4e0a\u8a18\u3044\u305a\u308c\u306essh\u30b3\u30de\u30f3\u30c9\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3082\u5b9f\u884c\u74b0\u5883\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\r\n[magtranetwork@localhost ~]# vim ssh-cmd\r\n<\/pre>\n
\r\n#!\/bin\/bash\r\n\r\nssh -C -o CompressionLevel=9 -i ~\/.ssh\/private_key.pem magtranetwork@magtranetwork.com "export PATH=\/usr\/local\/pyenv\/shims:\/usr\/local\/pyenv\/bin:\/usr\/local\/rbenv\/shims:\/usr\/local\/rbenv\/bin:\/usr\/local\/ndenv\/shims:\/usr\/local\/ndenv\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\\$HOME\/bin:\\$PATH && $*"\r\n\r\n<\/pre>\n

\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u306e\u30b5\u30fc\u30d0\u3067\u30b3\u30de\u30f3\u30c9\u3092\u305d\u306e\u307e\u307e\u5b9f\u884c\u3055\u305b\u308bSSH\u30e9\u30c3\u30d1\u30fc\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u4f8b<\/h3>\n
\r\n[magtranetwork@localhost ~]# chmod 755 ssh-cmd\r\n[magtranetwork@localhost ~]# .\/ssh-cmd whoami\r\nmagtranetwork\r\n[magtranetwork@localhost ~]# .\/ssh-cmd uname -a\r\nLinux ip-10-0-0-5 4.4.35-33.55.amzn1.x86_64 #1 SMP Tue Dec 6 20:30:04 UTC 2016 x86_64 x86_64 x86_64 GNU\/Linux\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u6700\u8fd1\u3067\u306f\u30d1\u30d6\u30ea\u30c3\u30af\u30af\u30e9\u30a6\u30c9\u304c\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3092\u4ecb\u3057\u3066\u30af\u30e9\u30a6\u30c9\u4e0a\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u969b\u306b\u306fSSH\u3092\u5fc5\u305a\u3068\u8a00\u3063\u3066\u3044\u3044\u307b\u3069\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002 SSH\u306f\u516c\u958b\u9375\u8a8d\u8a3c\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3,22,79,82],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5233"}],"collection":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/comments?post=5233"}],"version-history":[{"count":2,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5233\/revisions"}],"predecessor-version":[{"id":5247,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5233\/revisions\/5247"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=5233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=5233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=5233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}