{"id":54,"date":"2022-05-15T15:50:40","date_gmt":"2022-05-15T06:50:40","guid":{"rendered":"http:\/\/52.196.21.54.nip.io\/techblog\/?p=54"},"modified":"2023-02-24T01:52:40","modified_gmt":"2023-02-23T16:52:40","slug":"ubuntu-server%e3%81%a7ssh%e3%81%ae%e3%82%bb%e3%82%ad%e3%83%a5%e3%83%aa%e3%83%86%e3%82%a3%e3%82%92%e5%bc%b7%e5%8c%96%e3%81%99%e3%82%8b%ef%bc%88%e5%85%ac%e9%96%8b%e9%8d%b5%e8%aa%8d%e8%a8%bc%ef%bc%89","status":"publish","type":"post","link":"https:\/\/shugomatsuzawa.com\/techblog\/2022\/05\/15\/54\/","title":{"rendered":"Ubuntu Server\u3067SSH\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u5f37\u5316\u3059\u308b\uff08\u516c\u958b\u9375\u8a8d\u8a3c\uff09"},"content":{"rendered":"\n<p>\u6b63\u3057\u304f\u4f7f\u3048\u3070\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3088\u308a\u305a\u3063\u3068\u5b89\u5168\u6027\u304c\u9ad8\u307e\u308b\u306e\u304c\u516c\u958b\u9375\u8a8d\u8a3c\u3002<br>SSH\u3092\u4f7f\u3046\u306a\u3089\u662f\u975e\u3068\u3082\u8a2d\u5b9a\u3057\u305f\u3044\u3068\u3053\u308d\u3002<\/p>\n\n\n\n<p>\u307e\u305aMac\u5074\u3067\u9375\u3092\u4f5c\u3063\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir .ssh # ssh\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u306a\u3044\u5834\u5408\nchmod 700 .ssh\ncd .ssh\nssh-keygen<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter file in which to save the key (\/Users\/xxxx\/.ssh\/id_rsa): {\u4fdd\u5b58\u30d1\u30b9\u3068\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a}\nEnter passphrase (empty for no passphrase): {\u30d1\u30b9\u30d5\u30ec\u30fc\u30ba\u3092\u5165\u529b}\nEnter same passphrase again: {\u30d1\u30b9\u30d5\u30ec\u30fc\u30ba\u3092\u5165\u529b}<\/code><\/pre>\n\n\n\n<p>2\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u308b\u304c\u3001\u62e1\u5f35\u5b50<code>.pub<\/code>\u304c\u3064\u3044\u3066\u3044\u306a\u3044\u65b9\u304cMac\u5074\u3067\u4f7f\u3046\u79d8\u5bc6\u9375\u3002<br><code>.pub<\/code>\u3064\u3044\u3066\u3044\u308b\u65b9\u304c\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u4f7f\u3046\u516c\u958b\u9375\u3002<br>\u4ee5\u4e0b\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u4f5c\u696d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir .ssh # ssh\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u306a\u3044\u5834\u5408\nchmod 700 .ssh\ncd .ssh\nvim authorized_keys # \u516c\u958b\u9375\u3092\u30b3\u30d4\u30da\nchmod 600 authorized_keys<\/code><\/pre>\n\n\n\n<p><code>ssh<\/code>\u30b3\u30de\u30f3\u30c9\u306b<code>-i<\/code>\u3092\u3064\u3051\u3066\u79d8\u5bc6\u9375\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u6307\u5b9a\u3059\u308b\u3068\u4f7f\u3048\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -i .ssh\/id_rsa username@xxx.xxx.xxx.xxx<\/code><\/pre>\n\n\n\n<p>\/etc\/ssh\/sshd_config \u3092\u7de8\u96c6\u3057\u3066\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3092\u30aa\u30d5\u306b\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PasswordAuthentication no<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">SSH\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\uff08ssh\/config\uff09<\/h2>\n\n\n\n<p>\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304a\u3051\u3070\u3001\u6bce\u56de\u79d8\u5bc6\u9375\u3092\u6307\u5b9a\u3057\u306a\u304f\u3066\u3082\u7c21\u5358\u306a\u30b3\u30de\u30f3\u30c9\u3067\u63a5\u7d9a\u3067\u304d\u308b\u3002<br><code>~\/.ssh\/config<\/code>\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Host my_server xxx.xxx.xxx.xxx\n  HostName xxx.xxx.xxx.xxx\n  User username\n  IdentityFile ~\/.ssh\/id_rsa<\/code><\/pre>\n\n\n\n<p>Host\u306e\u5024\u3092\u4f7f\u3063\u3066\u63a5\u7d9a\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh my_server<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/knowledge.sakura.ad.jp\/3543\/\" data-type=\"URL\" data-id=\"https:\/\/knowledge.sakura.ad.jp\/3543\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u300c\u3088\u304f\u5206\u304b\u308b\u516c\u958b\u9375\u8a8d\u8a3c\u300d\uff5e\u521d\u5fc3\u8005\u3067\u3082\u3088\u304f\u308f\u304b\u308b\uff01VPS\u306b\u3088\u308bWeb\u30b5\u30fc\u30d0\u30fc\u904b\u7528\u8b1b\u5ea7(2) | \u3055\u304f\u3089\u306e\u30ca\u30ec\u30c3\u30b8<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u6b63\u3057\u304f\u4f7f\u3048\u3070\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3088\u308a\u305a\u3063\u3068\u5b89\u5168\u6027\u304c\u9ad8\u307e\u308b\u306e\u304c\u516c\u958b\u9375\u8a8d\u8a3c\u3002SSH\u3092\u4f7f\u3046\u306a\u3089\u662f\u975e\u3068\u3082\u8a2d\u5b9a\u3057\u305f\u3044\u3068\u3053\u308d\u3002 \u307e\u305aMac\u5074\u3067\u9375\u3092\u4f5c\u3063\u305f\u3002 2\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u308b\u304c\u3001\u62e1\u5f35\u5b50.pub\u304c\u3064\u3044\u3066\u3044\u306a\u3044\u65b9\u304cMac\u5074\u3067\u4f7f\u3046\u79d8\u5bc6\u9375 [&hellip;]","protected":false},"author":1,"featured_media":62,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[9,20,11,10],"class_list":["post-54","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-system-management","tag-linux","tag-ssh","tag-ubuntu","tag-memo"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2022\/05\/programming-g682c45857_1280.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":3,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/54\/revisions\/195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/media\/62"}],"wp:attachment":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}