{"id":1617,"date":"2025-09-18T08:52:38","date_gmt":"2025-09-18T00:52:38","guid":{"rendered":"https:\/\/swordofmorning.com\/?p=1617"},"modified":"2025-10-09T13:54:09","modified_gmt":"2025-10-09T05:54:09","slug":"trans-01","status":"publish","type":"post","link":"https:\/\/swordofmorning.com\/index.php\/2025\/09\/18\/trans-01\/","title":{"rendered":"\u5d4c\u5165\u5f0fLinux \u79fb\u690d SSH &#038; SFTP"},"content":{"rendered":"<h2>\u4e00\u3001\u914d\u7f6e\u73af\u5883<\/h2>\n<pre><code class=\"language-sh\"># \u8bbe\u7f6e\u4ea4\u53c9\u7f16\u8bd1\u73af\u5883\u53d8\u91cf\nexport CROSS_COMPILE=aarch64-linux-gnu-\nexport CC=${CROSS_COMPILE}gcc\nexport CXX=${CROSS_COMPILE}g++\nexport AR=${CROSS_COMPILE}ar\nexport STRIP=${CROSS_COMPILE}strip\nexport PATH=&quot;\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin:$PATH&quot;\n\n# \u8bbe\u7f6e\u76ee\u6807\u7cfb\u7edf\u8def\u5f84\nexport DROPBEAR_INSTALL_DIR=&quot;\/hdd\/Workspace\/VS839_SysDeps\/output\/dropbear&quot;\nmkdir -p $DROPBEAR_INSTALL_DIR<\/code><\/pre>\n<h2>\u4e8c\u3001\u7f16\u8bd1Dropbear<\/h2>\n<pre><code class=\"language-sh\"># 1. \u4e0b\u8f7dDropbear\u6e90\u7801\nwget https:\/\/matt.ucc.asn.au\/dropbear\/releases\/dropbear-2022.83.tar.bz2\ntar -xjf dropbear-2022.83.tar.bz2\ncd dropbear-2022.83\n\n# 2. \u914d\u7f6e\u7f16\u8bd1\u9009\u9879\n.\/configure \\\n    --host=aarch64-linux-gnu \\\n    --prefix=\/usr \\\n    --disable-zlib \\\n    --disable-pam \\\n    --disable-lastlog \\\n    --disable-utmp \\\n    --disable-utmpx \\\n    --disable-wtmp \\\n    --disable-wtmpx \\\n    --disable-loginfunc \\\n    --disable-pututline \\\n    --disable-pututxline\n\n# 3. \u7f16\u8bd1\nmake PROGRAMS=&quot;dropbear dbclient dropbearkey scp&quot;\n\n# 4. \u5b89\u88c5\u5230\u76ee\u6807\u6587\u4ef6\u7cfb\u7edf\nmake DESTDIR=$DROPBEAR_INSTALL_DIR install<\/code><\/pre>\n<h2>\u4e09\u3001\u677f\u7aef\u914d\u7f6eDropbear<\/h2>\n<pre><code class=\"language-sh\"># \u5728\u76ee\u6807\u6587\u4ef6\u7cfb\u7edf\u4e2d\u521b\u5efa\u5fc5\u8981\u7684\u76ee\u5f55\nmkdir -p \/etc\/dropbear\nmkdir -p \/var\/log\n\n# \u751f\u6210\u4e3b\u673a\u5bc6\u94a5\uff08\u5728\u5f00\u53d1\u677f\u4e0a\u6267\u884c\uff09\n# \u5c06\u4ee5\u4e0b\u547d\u4ee4\u6dfb\u52a0\u5230\u5f00\u53d1\u677f\u7684\u542f\u52a8\u811a\u672c\u4e2d\ncat &gt; \/etc\/init.d\/dropbear &lt;&lt; &#039;EOF&#039;\n#!\/bin\/sh\n\ncase &quot;$1&quot; in\n  start)\n    echo &quot;Starting dropbear SSH daemon...&quot;\n    # \u751f\u6210\u4e3b\u673a\u5bc6\u94a5\uff08\u5982\u679c\u4e0d\u5b58\u5728\uff09\n    [ ! -f \/etc\/dropbear\/dropbear_rsa_host_key ] &amp;&amp; dropbearkey -t rsa -f \/etc\/dropbear\/dropbear_rsa_host_key\n    [ ! -f \/etc\/dropbear\/dropbear_dss_host_key ] &amp;&amp; dropbearkey -t dss -f \/etc\/dropbear\/dropbear_dss_host_key\n    [ ! -f \/etc\/dropbear\/dropbear_ecdsa_host_key ] &amp;&amp; dropbearkey -t ecdsa -f \/etc\/dropbear\/dropbear_ecdsa_host_key\n\n    # \u542f\u52a8dropbear\n    dropbear -R\n    ;;\n  stop)\n    echo &quot;Stopping dropbear SSH daemon...&quot;\n    killall dropbear\n    ;;\n  *)\n    echo &quot;Usage: $0 {start|stop}&quot;\n    exit 1\n    ;;\nesac\nEOF\n\nchmod +x \/etc\/init.d\/dropbear<\/code><\/pre>\n<h2>\u56db\u3001OpenSSL<\/h2>\n<pre><code class=\"language-sh\">tar -xzf openssl-1.1.1w.tar.gz\n\n# \u6ce8\u610f\uff1a\u4e0d\u8981\u548c\u4e0a\u8ff0\u7684Dropbear\u914d\u7f6e\u7684CC\u91cd\u590d\u4e86\nunset CC CXX AR STRIP CROSS_COMPILE\n# \u8bbe\u7f6e\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u94fe\u73af\u5883\u53d8\u91cf\nexport CROSS_COMPILE=aarch64-linux-gnu-\nexport CC=${CROSS_COMPILE}gcc\nexport CXX=${CROSS_COMPILE}g++\nexport AR=${CROSS_COMPILE}ar\nexport RANLIB=${CROSS_COMPILE}ranlib\nexport STRIP=${CROSS_COMPILE}strip\nexport PATH=&quot;\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin:$PATH&quot;\n\n# \u8bbe\u7f6e\u5b89\u88c5\u76ee\u5f55\nexport OPENSSL_INSTALL_DIR=&quot;\/hdd\/Workspace\/VS839_SysDeps\/output\/openssl&quot;\nmkdir -p $OPENSSL_INSTALL_DIR\n\n.\/Configure linux-aarch64 \\\n    --prefix=$OPENSSL_INSTALL_DIR \\\n    --openssldir=$OPENSSL_INSTALL_DIR\/ssl \\\n    CC=\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin\/aarch64-linux-gnu-gcc \\\n    CXX=\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin\/aarch64-linux-gnu-g++ \\\n    AR=\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin\/aarch64-linux-gnu-ar \\\n    RANLIB=\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin\/aarch64-linux-gnu-ranlib \\\n    no-tests \\\n    no-fuzz-libfuzzer \\\n    no-fuzz-afl \\\n    no-async \\\n    no-egd \\\n    no-ui-console \\\n    no-dso \\\n    no-sock \\\n    no-dgram \\\n    no-hw \\\n    no-weak-ssl-ciphers\n\n# \u7f16\u8bd1OpenSSL\nmake -j8\n\n# \u5b89\u88c5\u5230\u6307\u5b9a\u76ee\u5f55\nmake install_sw<\/code><\/pre>\n<h2>SFTP<\/h2>\n<pre><code class=\"language-sh\">wget https:\/\/ftp.openbsd.org\/pub\/OpenBSD\/OpenSSH\/portable\/openssh-9.0p1.tar.gz\n\ntar -xzf openssh-9.0p1.tar.gz\ncd openssh-9.0p1\n\n# \u8bbe\u7f6e\u4ea4\u53c9\u7f16\u8bd1\u73af\u5883\nexport CROSS_COMPILE=aarch64-linux-gnu-\nexport CC=${CROSS_COMPILE}gcc\nexport CXX=${CROSS_COMPILE}g++\nexport AR=${CROSS_COMPILE}ar\nexport STRIP=${CROSS_COMPILE}strip\nexport RANLIB=${CROSS_COMPILE}ranlib\nexport PATH=&quot;\/hdd\/System\/VS819L\/vs-linux\/x86-arm\/gcc-linaro-7.5.0-aarch64-linux-gnu\/bin:$PATH&quot;\n\n# \u8bbe\u7f6eOpenSSL\u8def\u5f84\nexport OPENSSL_ROOT=&quot;\/hdd\/Workspace\/VS839_SysDeps\/output\/openssl&quot;\nexport PKG_CONFIG_PATH=&quot;$OPENSSL_ROOT\/lib\/pkgconfig:$PKG_CONFIG_PATH&quot;\n\n# \u8bbe\u7f6e\u8f93\u51fa\u76ee\u5f55\nexport OUTPUT_DIR=&quot;\/hdd\/Workspace\/VS839_SysDeps\/output\/openssh&quot;\n\n# \u914d\u7f6econfigure\u9009\u9879\uff0c\u91cd\u70b9\u5173\u6ce8\u7981\u7528zlib\u548c\u6307\u5b9aOpenSSL\u8def\u5f84\n.\/configure \\\n    --host=aarch64-linux-gnu \\\n    --target=aarch64-linux-gnu \\\n    --prefix=\/usr \\\n    --sysconfdir=\/etc\/ssh \\\n    --with-ssl-dir=$OPENSSL_ROOT \\\n    --with-ssl-engine \\\n    --without-zlib \\\n    --without-zlib-version-check \\\n    --disable-etc-default-login \\\n    --disable-lastlog \\\n    --disable-utmp \\\n    --disable-utmpx \\\n    --disable-wtmp \\\n    --disable-wtmpx \\\n    --disable-libutil \\\n    --disable-pututline \\\n    --disable-pututxline \\\n    --without-pam \\\n    --without-shadow \\\n    --without-tcp-wrappers \\\n    --without-libedit \\\n    --without-kerberos5 \\\n    --without-selinux \\\n    --with-cflags=&quot;-I$OPENSSL_ROOT\/include&quot; \\\n    --with-ldflags=&quot;-L$OPENSSL_ROOT\/lib&quot;\n\n# \u53ea\u7f16\u8bd1\u6211\u4eec\u9700\u8981\u7684sftp-server\nmake sftp-server\n\n# \u68c0\u67e5\u7f16\u8bd1\u51fa\u7684sftp-server\nls -la sftp-server\nfile sftp-server\n\n# \u521b\u5efa\u8f93\u51fa\u76ee\u5f55\u7ed3\u6784\nmkdir -p $OUTPUT_DIR\/usr\/libexec\nmkdir -p $OUTPUT_DIR\/usr\/bin\n\n# \u590d\u5236\u7f16\u8bd1\u7ed3\u679c\ncp sftp-server $OUTPUT_DIR\/usr\/libexec\/\n${CROSS_COMPILE}strip $OUTPUT_DIR\/usr\/libexec\/sftp-server\n\n# \u5982\u679c\u9700\u8981sftp\u5ba2\u6237\u7aef\uff0c\u4e5f\u53ef\u4ee5\u7f16\u8bd1\n# make sftp\n# cp sftp $OUTPUT_DIR\/usr\/bin\/\n\n# \u68c0\u67e5\u6700\u7ec8\u6587\u4ef6\nls -la $OUTPUT_DIR\/usr\/libexec\/sftp-server<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u914d\u7f6e\u73af\u5883 # \u8bbe\u7f6e\u4ea4\u53c9\u7f16\u8bd1\u73af\u5883\u53d8\u91cf export CROSS_COMPILE=aarch64-linux-gnu- expor &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[345],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/1617"}],"collection":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/comments?post=1617"}],"version-history":[{"count":1,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/1617\/revisions"}],"predecessor-version":[{"id":1618,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/1617\/revisions\/1618"}],"wp:attachment":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/media?parent=1617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/categories?post=1617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/tags?post=1617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}