{"id":299,"date":"2025-06-26T11:56:56","date_gmt":"2025-06-26T03:56:56","guid":{"rendered":"https:\/\/qkd.koudaipc.com\/?p=299"},"modified":"2025-06-26T11:56:56","modified_gmt":"2025-06-26T03:56:56","slug":"%e5%9c%a8-kpcos-yandi-1-01-%e4%b8%8a%e9%85%8d%e7%bd%ae-dropbear-%e4%bd%bf%e7%94%a8%e5%af%86%e9%92%a5%e7%99%bb%e5%bd%95","status":"publish","type":"post","link":"https:\/\/ns1.koudaipc.com\/en\/2025\/06\/26\/%e5%9c%a8-kpcos-yandi-1-01-%e4%b8%8a%e9%85%8d%e7%bd%ae-dropbear-%e4%bd%bf%e7%94%a8%e5%af%86%e9%92%a5%e7%99%bb%e5%bd%95\/","title":{"rendered":"\u5728 KPCOS\/YanDi 1.01 \u4e0a\u914d\u7f6e Dropbear \u4f7f\u7528\u5bc6\u94a5\u767b\u5f55"},"content":{"rendered":"<p>\u5728 KPCOS\/YanDi 1.01 \u4e0a\u914d\u7f6e Dropbear \u4f7f\u7528\u5bc6\u94a5\u767b\u5f55\u7684\u5b8c\u6574\u6307\u5357\u5982\u4e0b\uff08Dropbear \u662f\u8f7b\u91cf\u7ea7 SSH \u670d\u52a1\u5668\uff0c\u9002\u7528\u4e8e\u8d44\u6e90\u53d7\u9650\u73af\u5883\uff09\uff1a<\/p>\n<hr \/>\n<h3>\u6b65\u9aa4 1\uff1a\u5b89\u88c5 Dropbear<\/h3>\n<pre><code class=\"language-bash\">sudo apt update\nsudo apt install dropbear<\/code><\/pre>\n<hr \/>\n<h3>\u6b65\u9aa4 2\uff1a\u751f\u6210 SSH \u5bc6\u94a5\u5bf9\uff08\u5ba2\u6237\u7aef\u64cd\u4f5c\uff09<\/h3>\n<p>\u5728\u60a8\u7684\u672c\u5730\u673a\u5668\u4e0a\u751f\u6210\u5bc6\u94a5\uff1a<\/p>\n<pre><code class=\"language-bash\">ssh-keygen -t ed25519 -f ~\/.ssh\/dropbear_key\n# \u6216\u4f7f\u7528 RSA\uff1assh-keygen -t rsa -b 4096 -f ~\/.ssh\/dropbear_key<\/code><\/pre>\n<hr \/>\n<h3>\u6b65\u9aa4 3\uff1a\u914d\u7f6e Dropbear \u670d\u52a1<\/h3>\n<h4>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a<\/h4>\n<pre><code class=\"language-bash\">sudo nano \/etc\/default\/dropbear<\/code><\/pre>\n<p>\u4fee\u6539\u4ee5\u4e0b\u53c2\u6570\uff1a<\/p>\n<pre><code class=\"language-ini\"># \u542f\u7528 SSH \u670d\u52a1\nNO_START=0\n\n# \u76d1\u542c\u7aef\u53e3\uff08\u9ed8\u8ba4 22\uff09\nDROPBEAR_PORT=22\n\n# \u542f\u7528\u516c\u94a5\u8ba4\u8bc1\uff08\u5173\u952e\uff01\uff09\nDROPBEAR_EXTRA_ARGS=&quot;-s -j -k&quot; \n\n# \u5176\u4ed6\u63a8\u8350\u5b89\u5168\u8bbe\u7f6e\nDROPBEAR_BANNER=&quot;\/etc\/dropbear\/banner&quot;<\/code><\/pre>\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<ul>\n<li><code>-s<\/code>\uff1a\u7981\u7528\u5bc6\u7801\u767b\u5f55\uff08\u5f3a\u5236\u5bc6\u94a5\u8ba4\u8bc1\uff09<\/li>\n<li><code>-j<\/code>\uff1a\u7981\u7528\u672c\u5730\u7aef\u53e3\u8f6c\u53d1<\/li>\n<li><code>-k<\/code>\uff1a\u7981\u7528\u8fdc\u7a0b\u7aef\u53e3\u8f6c\u53d1<\/li>\n<\/ul>\n<hr \/>\n<h3>\u6b65\u9aa4 4\uff1a\u5c06\u516c\u94a5\u590d\u5236\u5230\u670d\u52a1\u5668<\/h3>\n<h4>\u65b9\u6cd5 A\uff1a\u624b\u52a8\u590d\u5236<\/h4>\n<ol>\n<li>\u67e5\u770b\u516c\u94a5\u5185\u5bb9\uff1a\n<pre><code class=\"language-bash\">cat ~\/.ssh\/dropbear_key.pub<\/code><\/pre>\n<\/li>\n<li>\u5728\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u6388\u6743\u6587\u4ef6\uff1a\n<pre><code class=\"language-bash\">sudo mkdir -p \/etc\/dropbear\necho \"ssh-ed25519 AAAAC3Nz... your_comment\" | sudo tee -a \/etc\/dropbear\/authorized_keys\n# \u6216\u4f7f\u7528\uff1asudo nano \/etc\/dropbear\/authorized_keys<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>\u65b9\u6cd5 B\uff1a\u4f7f\u7528 <code>ssh-copy-id<\/code> (\u9700\u4e34\u65f6\u5f00\u542f\u5bc6\u7801\u767b\u5f55)<\/h4>\n<ol>\n<li>\u4e34\u65f6\u5141\u8bb8\u5bc6\u7801\u767b\u5f55\uff08\u7f16\u8f91 <code>\/etc\/default\/dropbear<\/code> \u79fb\u9664 <code>-s<\/code> \u53c2\u6570\uff09<\/li>\n<li>\u590d\u5236\u5bc6\u94a5\uff1a\n<pre><code class=\"language-bash\">ssh-copy-id -i ~\/.ssh\/dropbear_key.pub user@your_server_ip<\/code><\/pre>\n<\/li>\n<li>\u5b8c\u6210\u540e\u91cd\u65b0\u7981\u7528\u5bc6\u7801\u767b\u5f55<\/li>\n<\/ol>\n<hr \/>\n<h3>\u6b65\u9aa4 5\uff1a\u8bbe\u7f6e\u6587\u4ef6\u6743\u9650<\/h3>\n<pre><code class=\"language-bash\">sudo chmod 644 \/etc\/dropbear\/authorized_keys\nsudo chown root:root \/etc\/dropbear\/authorized_keys<\/code><\/pre>\n<hr \/>\n<h3>\u6b65\u9aa4 6\uff1a\u91cd\u542f Dropbear \u670d\u52a1<\/h3>\n<pre><code class=\"language-bash\">sudo systemctl restart dropbear<\/code><\/pre>\n<hr \/>\n<h3>\u6b65\u9aa4 7\uff1a\u6d4b\u8bd5\u5bc6\u94a5\u767b\u5f55<\/h3>\n<pre><code class=\"language-bash\">ssh -i ~\/.ssh\/dropbear_key user@your_server_ip<\/code><\/pre>\n<hr \/>\n<h3>\u6b65\u9aa4 8\uff1a\u5b8c\u5168\u7981\u7528\u5bc6\u7801\u767b\u5f55\uff08\u53ef\u9009\u4f46\u63a8\u8350\uff09<\/h3>\n<p>\u7f16\u8f91 <code>\/etc\/default\/dropbear<\/code> \u786e\u4fdd\u5305\u542b\uff1a<\/p>\n<pre><code class=\"language-ini\">DROPBEAR_EXTRA_ARGS=&quot;-s -j -k&quot;<\/code><\/pre>\n<hr \/>\n<h3>\u6b65\u9aa4 9\uff1a\u9632\u706b\u5899\u914d\u7f6e<\/h3>\n<pre><code class=\"language-bash\">sudo ufw allow 22\nsudo ufw enable<\/code><\/pre>\n<hr \/>\n<h3>\u6545\u969c\u6392\u9664<\/h3>\n<h4>1. \u767b\u5f55\u5931\u8d25\uff1a<code>Permission denied (publickey)<\/code><\/h4>\n<ul>\n<li>\u68c0\u67e5\u516c\u94a5\u683c\u5f0f\uff1aDropbear \u53ea\u652f\u6301 <code>ssh-rsa<\/code> \u6216 <code>ssh-ed25519<\/code>\n<pre><code class=\"language-bash\"># \u8f6c\u6362 OpenSSH \u5bc6\u94a5\u4e3a Dropbear \u683c\u5f0f\ndropbearconvert openssh dropbear ~\/.ssh\/dropbear_key ~\/.ssh\/dropbear_key_db<\/code><\/pre>\n<\/li>\n<li>\u9a8c\u8bc1\u6587\u4ef6\u6743\u9650\uff1a\n<pre><code class=\"language-bash\">sudo chmod 700 \/etc\/dropbear\nsudo chmod 600 \/etc\/dropbear\/authorized_keys<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>2. \u5bc6\u94a5\u7c7b\u578b\u4e0d\u652f\u6301<\/h4>\n<p>\u5982\u679c\u4f7f\u7528\u8f83\u65b0\u7684 OpenSSH \u5bc6\u94a5\u683c\u5f0f\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u751f\u6210\u517c\u5bb9\u7684 RSA \u5bc6\u94a5\nssh-keygen -m PEM -t rsa -b 4096 -f ~\/.ssh\/dropbear_rsa_key<\/code><\/pre>\n<h4>3. \u67e5\u770b\u65e5\u5fd7<\/h4>\n<pre><code class=\"language-bash\">sudo journalctl -u dropbear -f<\/code><\/pre>\n<hr \/>\n<h3>\u5b89\u5168\u52a0\u56fa\u5efa\u8bae<\/h3>\n<ol>\n<li>\n<p><strong>\u66f4\u6539\u9ed8\u8ba4\u7aef\u53e3<\/strong>\uff1a<\/p>\n<pre><code class=\"language-ini\"># \/etc\/default\/dropbear\nDROPBEAR_PORT=2222<\/code><\/pre>\n<pre><code class=\"language-bash\">sudo ufw allow 2222<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u767b\u5f55\u6a2a\u5e45<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo nano \/etc\/dropbear\/banner<\/code><\/pre>\n<p>\u5185\u5bb9\u793a\u4f8b\uff1a<\/p>\n<pre><code>WARNING: Unauthorized access prohibited!<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u9650\u5236\u7528\u6237\u8bbf\u95ee<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo nano \/etc\/shells<\/code><\/pre>\n<p>\u6dfb\u52a0\u6709\u6548 shell\uff08\u5982 <code>\/bin\/bash<\/code>\uff09\uff0c\u7136\u540e\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo usermod -s \/usr\/sbin\/nologin username<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u81ea\u52a8\u66f4\u65b0<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo apt install unattended-upgrades\nsudo dpkg-reconfigure unattended-upgrades<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\u6700\u7ec8\u9a8c\u8bc1<\/h3>\n<pre><code class=\"language-bash\"># \u6210\u529f\u767b\u5f55\nssh -i ~\/.ssh\/dropbear_key -p 2222 user@server_ip\n\n# \u6d4b\u8bd5\u5bc6\u7801\u767b\u5f55\u5e94\u5931\u8d25\nssh user@server_ip\n# \u5e94\u8fd4\u56de\uff1aPermission denied (publickey)<\/code><\/pre>\n<blockquote>\n<p>\u26a0\ufe0f <strong>\u91cd\u8981\u63d0\u9192<\/strong>\uff1a<br \/>\n\u5728\u7981\u7528\u5bc6\u7801\u767b\u5f55\u524d\uff0c\u8bf7\u786e\u4fdd\u5bc6\u94a5\u767b\u5f55\u6b63\u5e38\u5de5\u4f5c\uff01\u5efa\u8bae\u4fdd\u7559\u53e6\u4e00\u4e2a\u6d3b\u52a8\u4f1a\u8bdd\u4ee5\u9632\u914d\u7f6e\u9519\u8bef\u5bfc\u81f4\u9501\u5b9a\u3002<\/p>\n<\/blockquote>\n<p>\u6b64\u914d\u7f6e\u63d0\u4f9b\uff1a<\/p>\n<ul>\n<li>\u2705 \u57fa\u4e8e\u5bc6\u94a5\u7684\u5b89\u5168\u8ba4\u8bc1<\/li>\n<li>\u2705 \u7981\u7528\u5bc6\u7801\u767b\u5f55<\/li>\n<li>\u2705 \u9650\u5236\u7aef\u53e3\u8f6c\u53d1<\/li>\n<li>\u2705 \u7cfb\u7edf\u7ea7\u5bc6\u94a5\u7ba1\u7406\uff08\u975e\u7528\u6237\u7ea7\uff09<\/li>\n<li>\u2705 \u517c\u5bb9\u5d4c\u5165\u5f0f\u8bbe\u5907\u548c\u8d44\u6e90\u53d7\u9650\u73af\u5883<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>\u5728 KPCOS\/YanDi 1.01 \u4e0a\u914d\u7f6e Dropbear \u4f7f\u7528\u5bc6\u94a5\u767b\u5f55\u7684\u5b8c\u6574\u6307\u5357\u5982\u4e0b\uff08Dropbear  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pmpro_default_level":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-299","post","type-post","status-publish","format-standard","hentry","category-uncategorized","pmpro-has-access"],"_links":{"self":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/comments?post=299"}],"version-history":[{"count":1,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/299\/revisions\/300"}],"wp:attachment":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/media?parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/categories?post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/tags?post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}