{"id":7950,"date":"2018-10-27T01:08:12","date_gmt":"2018-10-26T17:08:12","guid":{"rendered":"https:\/\/4563.org\/?p=7950"},"modified":"2019-12-18T05:33:03","modified_gmt":"2019-12-17T21:33:03","slug":"google-cloud-platformgcp%e7%9a%84google-compute-enginegcevm%e5%ae%9e%e4%be%8b-ssh-root-%e7%94%a8%e6%88%b7%e5%af%86%e7%a0%81%e7%99%bb%e5%bd%95%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=7950","title":{"rendered":"Google Compute Engine(GCE)VM\u5b9e\u4f8b SSH root \u7528\u6237\u5bc6\u7801\u767b\u5f55\u6559\u7a0b"},"content":{"rendered":"<header class=\"kratos-entry-header\">\n<div class=\"kratos-post-meta text-center\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-7958\" src=\"https:\/\/4563.org\/wp-content\/uploads\/2018\/10\/20181026_171502.png\" alt=\"\" width=\"631\" height=\"378\" \/><\/div>\n<\/header>\n<div class=\"kratos-post-content\">\n<p>\u6700\u8fd1Google Cloud Platform(GCP)\u8c37\u6b4c\u4e91\u7684Google Compute Engine(GCE)\u6bd4\u8f83\u70ed\u95e8\uff0c\u53d7\u5230\u56fd\u5185\u4f17\u591a\u7f8a\u6bdb\u515a\u8ffd\u6367\uff0c\u597d\u591a\u670b\u53cb\u90fd\u60f3\u529e\u6cd5\u53bb\u529e\u5404\u79cd\u4fe1\u7528\u5361\u6765\u7533\u8bf7GCP\u3002\u4f46\u662f\u6211\u4eec\u7533\u8bf7\u5e76\u6dfb\u52a0\u5b9e\u4f8b\u540e\u4f1a\u53d1\u73b0Google Compute Engine(GCE)\u7684VM\u5b9e\u4f8b\u7684SSH\u53ea\u80fd\u7528key\u5bc6\u94a5\u767b\u5f55\uff0croot\u7528\u6237\u65e0\u6cd5\u4f7f\u7528\u8d26\u53f7\u5bc6\u7801\u767b\u5f55\u3002\u8fd9\u6837\u6709\u65f6\u5019\u4f7f\u7528\u4e00\u4e9bftp\u5de5\u5177\u8fdb\u884c\u7cfb\u7edf\u6587\u4ef6\u4fee\u6539\u4f1a\u6709\u4e9b\u4e0d\u65b9\u4fbf\u3002<\/p>\n<p>\uff08\u4e3a\u4e86\u65b9\u4fbf\u800c\u5f00\u542froot\u7528\u6237\u5bc6\u7801\u767b\u5f55\u4ee3\u8868\u7740\u6211\u4eec\u5c06\u964d\u4f4e\u7cfb\u7edf\u5b89\u5168\u7ea7\u522b\uff0c\u8bf7\u659f\u914c\u540e\u8fdb\u884c\u64cd\u4f5c\uff01\uff09<\/p>\n<p>\u90a3\u4e48\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u8bb0\u5f55\u4e0b\u5982\u4f55\u5f00\u542fGoogle Cloud Platform(GCP)\u8c37\u6b4c\u4e91Google Compute Engine(GCE)VM\u5b9e\u4f8bssh\u7528root\u8d26\u6237\u5bc6\u7801\u767b\u9646\u3002<\/p>\n<p>\u9996\u5148\u6211\u4eec\u767b\u5f55Google Compute Engine(GCE)VM\u5b9e\u4f8b\u5217\u8868\uff0c\u5728\u6211\u4eec\u60f3\u8981\u5f00\u542froot\u7528\u6237\u5bc6\u7801\u767b\u5f55\u7684VM\u5b9e\u4f8b\u5217\u4e2d\u7684\u201cSSH\u201d\u83dc\u5355\u9009\u9879\u4e0b\uff0c\u9009\u62e9\u201c\u5728\u6d4f\u89c8\u5668\u7a97\u53e3\u4e2d\u6253\u5f00\u201d\u3002<\/p>\n<p>\u7136\u540e\u4f7f\u7528sudo su\u547d\u4ee4\u63d0\u5347\u7528\u6237\u6743\u9650\uff0c\u5207\u6362\u4e3aroot\u7528\u6237\u3002<\/p>\n<blockquote><p>sudo su<\/p><\/blockquote>\n<p>\u7136\u540e\u7f16\u8f91\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6sshd_config<\/p>\n<blockquote><p>vi \/etc\/ssh\/sshd_config<\/p><\/blockquote>\n<p>\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u8f93\u5165\u6cd5\u5207\u6362\u4e3a\u82f1\u6587\u6309\u201cA\u201d\u8fdb\u5165\u7f16\u8f91\u4fee\u6539\u6a21\u5f0f\u3002<\/p>\n<p>\u4fee\u6539\u5176\u4e2d\u4fe1\u606f<\/p>\n<blockquote><p># Authenticat ion:<br \/>\nLoginGraceTime 2<br \/>\nPermitRootLogin yes \/\/\u628a\u9ed8\u8ba4\u7684no\uff0c\u6539\u4e3ayes<br \/>\nStrictModes yes \/\/\u628a\u9ed8\u8ba4\u7684no\uff0c\u6539\u4e3ayes<\/p><\/blockquote>\n<p>\u5728\u5f80\u4e0b\u7ffb<\/p>\n<blockquote><p># To di sable tunne led clear text pas swords, change to no here!<br \/>\nPasswordAuthentication yes \/\/\u628a\u9ed8\u8ba4\u7684no\uff0c\u6539\u4e3ayes<\/p><\/blockquote>\n<p>\u65e2\u7136\u5df2\u7ecf\u6253\u5f00ssh\u7684\u7528\u6237\u5bc6\u7801\u767b\u5f55\u529f\u80fd\uff0c\u4e3a\u4e86\u66f4\u52a0\u5b89\u5168\uff0c\u6211\u4eec\u53ef\u4ee5\u987a\u4fbf\u628a\u9ed8\u8ba4\u7aef\u53e3\u4fee\u6539\u4e3a\u81ea\u5b9a\u4e49\u7aef\u53e3\u53f7\u3002\u5982\u679c\u4f60\u8fd9\u6837\u505a\u4e86\uff0c\u4f1a\u4f7f\u4f60\u7684vps\u5b89\u5168\u6027\u66f4\u9ad8\uff0c\u4f46\u662f\u4e5f\u610f\u5473\u7740\u4e0a\u9762\u7b2c\u4e00\u6b65\u5728\u6d4f\u89c8\u5668\u4e2d\u7684VM\u5b9e\u4f8b\u5217\u201cSSH\u201d\u83dc\u5355\u9009\u9879\u4e0b\u201c\u5728\u6d4f\u89c8\u5668\u7a97\u53e3\u4e2d\u6253\u5f00\u201d\u7f51\u9875\u7248\u201cSSH\u201d\u4e0d\u80fd\u4f7f\u7528\u4e86\u3002\u4fee\u6539\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5728\u4e0a\u4e00\u6b65\u7f16\u8f91\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6sshd_config\u4e2d\u540c\u65f6\u4fee\u6539Port\u540e\u9762\u7684\u6570\u5b57\u3002<\/p>\n<blockquote><p>Port 22 \/\/\u628a\u9ed8\u8ba4\u4e3a22\u7aef\u53e3\uff0c\u6539\u4e3a\u81ea\u5df1\u60f3\u8981\u7684\u9ad8\u6bb5\u4f4d\u7aef\u53e3\uff0c\u5c3d\u91cf\u96be\u731c\u70b9<\/p><\/blockquote>\n<p>\u7136\u540e\u6309\u201cesc\u201d\uff0c\u8f93\u5165\u201c:wq\u201d\u8fdb\u884c\u7f16\u8f91\u4fdd\u5b58\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u4e3aroot\u7528\u6237\u914d\u7f6e\u4e00\u4e2a\u5bc6\u7801\uff1a<\/p>\n<blockquote><p>passwd root<\/p><\/blockquote>\n<p>\u63d0\u793a\u201cEnter new UNIX password:\u201d\u8ba9\u6211\u4eec\u8f93\u5165\u4e00\u4e2a\u65b0\u5bc6\u7801\uff0c\u5bc6\u7801\u4e00\u5b9a\u8981\u957f\u6700\u597d15\u4f4d\u4ee5\u4e0a\u3001\u6570\u5b57\u3001\u82f1\u6587\u5927\u5c0f\u5199\u3001\u5b57\u7b26\u90fd\u5177\u5907\u6700\u597d\u3002\u627e\u4e2a\u5b89\u5168\u5730\u65b9\u8bb0\u5f55\u597d\u5c31\u884c\u3002<\/p>\n<p>\u7136\u540e\u56de\u8f66\u63d0\u793a\u201cRetype new UNIX pas Sword:\u201d\u9a8c\u8bc1\u4e0a\u9762\u8f93\u5165\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u91cd\u542fSSH\u670d\u52a1\u4f7f\u6211\u4eec\u7684\u4fee\u6539\u751f\u6548\u3002<\/p>\n<blockquote>\n<pre class=\"prettyprint\"><code class=\"hljs  has-numbering\">service sshd restart<\/code><\/pre>\n<\/blockquote>\n<p>\u5230\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u9000\u51fa\u7f51\u9875\u7248SSH\uff0c\u4f7f\u7528\u7535\u8111\u7ec8\u7aef\u201cCMD\u201d\u767b\u5f55\u4ee5\u9a8c\u8bc1\u6211\u4eec\u7684\u4fee\u6539\u662f\u5426\u6210\u529f\u3002<\/p>\n<blockquote><p>ssh -p \u4fee\u6539\u7684\u7aef\u53e3\u53f7 root@111.111.111.111<\/p><\/blockquote>\n<p>\u5230\u8fd9\u91cc\u6211\u4eec\u5c31\u6210\u529f\u7684\u4f7f\u7528root\u7528\u6237\u5bc6\u7801\u767b\u5f55Google Compute Engine(GCE)VM\u5b9e\u4f8b\u7684SSH\u4e86\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1Google Cloud Pl&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/7950"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7950"}],"version-history":[{"count":7,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/7950\/revisions"}],"predecessor-version":[{"id":11988,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/7950\/revisions\/11988"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7950"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}