{"id":744,"date":"2023-10-03T09:01:01","date_gmt":"2023-10-03T01:01:01","guid":{"rendered":""},"modified":"2023-10-03T09:01:01","modified_gmt":"2023-10-03T01:01:01","slug":"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55","status":"publish","type":"post","link":"https:\/\/mushiming.com\/744.html","title":{"rendered":"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

1. ssh\u767b\u5f55\u63d0\u4f9b\u4e24\u79cd\u8ba4\u8bc1\u65b9\u5f0f\uff1a<\/h2>\n
    \n
  1. \u91c7\u7528\u53e3\u4ee4\u8ba4\u8bc1\u65b9\u5f0f\uff08\u8f83\u4e3a\u5e38\u7528\uff09<\/li>\n
  2. \u53e6\u5916\u4e00\u79cd\u5219\u662f\u4f7f\u7528\u516c\u94a5\u548c\u79c1\u94a5\u8fdb\u884c\u767b\u5f55<\/li>\n<\/ol>\n

    2. \u7b2c\u4e8c\u79cd\u516c\u94a5\u79c1\u94a5\u767b\u5f55\u65b9\u5f0f\u4e3b\u8981\u5206\u4e3a\u4e09\u6b65\uff1a<\/h2>\n
    1. \u751f\u6210\u5bc6\u94a5\uff08\u516c\u94a5\u548c\u79c1\u94a5\uff09\n2. \u653e\u7f6e\u516c\u94a5\uff08Public Key\uff09\u5230\u670d\u52a1\u5668~\/.ssh\/authorized_key\u6587\u4ef6\u4e2d\n3. \u62f7\u8d1d\u79c1\u94a5\uff08Private Key\uff09\u81ea\u5df1\u59a5\u5584\u4fdd\u5b58\uff0c\u7528\u4e8e\u8ba4\u8bc1\n4. \u914d\u7f6e\u4f7f\u7528ssh\u5ba2\u6237\u7aef\u4f7f\u7528\u5bc6\u94a5\n<\/code><\/pre>\n

    3. \u4f7f\u7528\u547d\u4ee4\u751f\u6210\u516c\u94a5\u79c1\u94a5<\/h2>\n
      \n
    1. \n

      \u4f7f\u7528\u547d\u4ee4\u751f\u6210\u516c\u94a5\u79c1\u94a5<\/p>\n

      #1. \u751f\u6210\u516c\u94a5\u548c\u79c1\u94a5<\/span>\n[<\/span>root@home:~$]<\/span> ssh-keygen\n#2. \u5f39\u51fa\u63d0\u793a<\/span>\nGenerating public\/private rsa key pair.\n#3. \u9009\u62e9\u5b58\u653ekey\u7684\u6587\u4ef6\u7684\u4f4d\u7f6e<\/span>\nEnter file<\/span> in<\/span> which<\/span> to save the key (<\/span>\/home\/.ssh\/id_rsa)<\/span>:\n#4. \u63d0\u793a\u8f93\u5165\u751f\u6210\u516c\u94a5\u79c1\u94a5\u4f7f\u7528\u7684\u5bc6\u7801\uff0c\u53ef\u4ee5\u9ed8\u8ba4\uff0c\u76f4\u63a5\u56de\u8f66\u5c31\u884c<\/span>\nEnter passphrase (<\/span>empty for<\/span> no passphrase)<\/span>:\nEnter same passphrase again: \n#5. \u663e\u793a\u516c\u94a5\u79c1\u94a5\u751f\u6210\u7684\u4f4d\u7f6e\uff0c\u4e0d\u5e26.pub\u7684\u662f\u79c1\u94a5\uff0c\u5e26.pub\u662f\u516c\u94a5<\/span>\nYour identification has been saved in<\/span> \/home\/.ssh\/id_rsa.\nYour public key has been saved in<\/span> \/home\/.ssh\/id_rsa.pub.\n#6. \u5269\u4f59\u7684\u8f93\u51fa\u7684\u4fe1\u606f<\/span>\nThe key fingerprint is:\nSHA256:bEnqIod+P9hUbwjAvTLJX8WClWIgPDnxFqxm\/ZSSPTg zhangfa@xjtuPC2\nThe key's randomart image is:\n+---[<\/span>RSA 2048<\/span>]<\/span>----+\n|<\/span> .o=<\/span>oo o.o       |<\/span>\n|<\/span>  =<\/span>o+.=<\/span> o o      |<\/span>\n|<\/span>   *oB +.o       |<\/span>\n|<\/span>  +.E B+o.       |<\/span>\n|<\/span> o   O.=<\/span>So       |<\/span>\n|<\/span>   .<\/span> .+..<\/span> o      |<\/span>\n|<\/span>  o o+.  .<\/span>       |<\/span>\n|<\/span> .<\/span> oo.o          |<\/span>\n|<\/span>  ..<\/span> ..<\/span>.         |<\/span>\n+----[<\/span>SHA256]<\/span>-----+\n<\/code><\/pre>\n<\/li>\n
    2. \n

      \u5728\u670d\u52a1\u5668\u4e0a\u6ce8\u518c\u516c\u94a5<\/p>\n

      [<\/span>root@home:~]<\/span>$ cd<\/span> .ssh\/\n# \u5c06\u521a\u521a\u7684\u516c\u94a5\u6ce8\u518c\u5230authorized_keys\u4e2d<\/span>\n[<\/span>root@home .ssh]<\/span>$ cat<\/span> id_rsa_2048.pub >><\/span> authorized_keys\n<\/code><\/pre>\n

      \u6ce8\u610f\uff1a\u5982\u4f55\u6743\u9650\u4e0d\u591f\uff0c\u5219\u53ef\u4ee5\u8fdb\u884c\u6743\u9650\u4fee\u6539<\/p>\n

      [<\/span>root@home:~]<\/span>$ chmod<\/span> 600<\/span> authorized_keys\n[<\/span>root@home:~]<\/span>$ chmod<\/span> 700<\/span> ~\/.ssh\n<\/code><\/pre>\n<\/li>\n
    3. \n

      \u4e0b\u8f7d\u516c\u94a5\uff0c\u4f7f\u7528\u79c1\u94a5\u8fdb\u884c\u8ba4\u8bc1\u767b\u5f55<\/p>\n<\/li>\n<\/ol>\n

      \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
      \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
      \u70b9\u51fb\u786e\u5b9a\u8fde\u63a5\u5373\u53ef<\/p>\n

      4. \u4f7f\u7528\u81ea\u5e26\u5de5\u5177\u751f\u6210\u516c\u94a5\u79c1\u94a5<\/h2>\n
        \n
      1. \u5148\u8fde\u63a5\u5230\u8981\u914d\u7f6e\u516c\u94a5\u79c1\u94a5\u7684\u670d\u52a1\u5668<\/li>\n
      2. \u8fdb\u884c\u914d\u7f6e
        \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
        \u63a5\u7740\u4e0b\u4e00\u6b65
        \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
        \u63a5\u7740\u4e0b\u4e00\u6b65
        \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
        \u70b9\u51fb\u4e0b\u4e00\u6b65
        \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
        \u7136\u540e\u5f39\u51fa\u79c1\u94a5\u754c\u9762\uff0c\u7528\u4e8e\u540e\u7eed\u7684\u8fde\u63a5\uff0c\u8bf7\u59a5\u5584\u4fdd\u5b58
        \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55<\/li>\n
      3. \u5c06\u4fdd\u5b58\u672c\u5730\u7684\u5e26\u6709\u5c3e\u7f00.pub\u7684\u516c\u94a5\u653e\u5230\u7528\u6237.ssh\/\u91cc
        \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55
        \u518d\u5c06\u516c\u94a5\u6ce8\u518c\u5230\u6388\u6743key\u6587\u4ef6authorized_keys\u91cc<\/li>\n<\/ol>\n
        \t[<\/span>root@home:~]<\/span>$ cd<\/span> .ssh\/\n\t# \u5c06\u521a\u521a\u7684\u516c\u94a5\u6ce8\u518c\u5230authorized_keys\u4e2d<\/span>\n\t[<\/span>root@home .ssh]<\/span>$ cat<\/span> id_rsa.pub >><\/span> authorized_keys\n<\/code><\/pre>\n
          \n
        1. \u4f7f\u7528ssh\u8fdb\u884c\u767b\u5f55
          \"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f55<\/li>\n<\/ol>\n

          5. \u4ee5\u4e0a\u4e3a\u4e24\u79cd\u751f\u6210\u516c\u94a5\u79c1\u94a5\u7684\u65b9\u5f0f\u5e76\u8fde\u63a5\u5230\u670d\u52a1\u5668\uff0c\u6709\u95ee\u9898\u8bf7\u7559\u8a00<\/h2>\n","protected":false},"excerpt":{"rendered":"xshell\u751f\u6210\u516c\u94a5\u79c1\u94a5\u5e76\u5b9e\u73b0\u767b\u5f551.ssh\u767b\u5f55\u63d0\u4f9b\u4e24\u79cd\u8ba4\u8bc1\u65b9\u5f0f\uff1a\u91c7\u7528\u53e3\u4ee4\u8ba4\u8bc1\u65b9\u5f0f\uff08\u8f83\u4e3a\u5e38\u7528\uff09\u53e6\u5916\u4e00\u79cd\u5219\u662f\u4f7f\u7528\u516c\u94a5\u548c\u79c1\u94a5\u8fdb\u884c\u767b\u5f55...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/744"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=744"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/744\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}