{"id":288473,"date":"2018-08-24T14:35:02","date_gmt":"2018-08-24T10:35:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=288473"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=288473","title":{"rendered":"Bonding \u0438 SSH \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 initramfs"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419915\/\" class=\"post__text post__text-html js-mediator-article\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mc\/mz\/-h\/mcmz-h3bsxctbh1ka8wxdtdnvqs.png\"><\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u044f\u043a\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/habr.com\/post\/359344\">\u0412 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u043c NAS<\/a>, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043d\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044f \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u043d\u0438\u0436\u0430\u043b\u043e \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0431\u044b\u043b\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0439, \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u0438 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u0438\u0447\u0435\u0441\u0442\u0432\u043e: \u0437\u0430 \u0442\u0440\u0438 \u043c\u0435\u0441\u044f\u0446\u0430 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u0418\u0411\u041f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u043a\u0440\u0430\u0442\u043a\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0431\u043e\u0438 \u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043e\u0442 \u0431\u0430\u0442\u0430\u0440\u0435\u0439 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0441\u0430 (\u0445\u043e\u0442\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u2014 \u043e\u043a\u043e\u043b\u043e \u0447\u0430\u0441\u0430), \u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0430\u043a\u043e\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0435\u0437\u0434\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0433\u043e\u0440\u043e\u0434.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <a href=\"https:\/\/habr.com\/post\/359344\/#comment_18916925\">\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0435<\/a> \u043e\u0442 <a href=\"https:\/\/habr.com\/users\/valdikss\/\" class=\"user_link\">ValdikSS<\/a>, \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0440\u0435\u0448\u0435\u043d\u0430. \u041d\u043e&#8230;<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/l0\/xu\/c3\/l0xuc38iobnzstjrcx204y9opeg.jpeg\"><\/p>\n<p>  <\/p>\n<p>\u041c\u043d\u0435 \u0431\u044b\u043b \u043d\u0443\u0436\u0435\u043d \u0431\u043e\u043d\u0434\u0438\u043d\u0433 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e SSH.<br \/>  \u0410 \u043c\u0430\u043d\u0443\u0430\u043b\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u043c\u043d\u0435 \u043d\u0430\u0434\u043e, \u044f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u0431\u043e\u043d\u0434\u0438\u043d\u0433\u043e\u043c \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c IP, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0442\u0430\u043a \u0438 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<p><strong>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a NAS \u0438 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/strong><\/p>\n<p>  <\/p>\n<h1 id=\"bonding-v-initramfs\">\u0411\u043e\u043d\u0434\u0438\u043d\u0433 \u0432 initramfs<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u0432 NAS \u0434\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043e\u0434\u0438\u043d \u043a\u0430\u043d\u0430\u043b, \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0418\u0437 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 <a href=\"https:\/\/serverfault.com\/questions\/472349\/using-nfs-root-with-bonded-interfaces\">&#171;Using NFS-root with bonded interfaces&#187;<\/a> \u044f \u0432\u0437\u044f\u043b \u0441\u043a\u0440\u0438\u043f\u0442.<br \/>  \u0421\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/backdrift.org\/manage-linux-bonding-without-ifenslave-using-sysfs\">&#171;How to manage linux bonding without ifenslave using sysfs&#187;<\/a> \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0431\u043e\u043d\u0434\u0438\u043d\u0433\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 initramfs \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0442\u0438.<br \/>  \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">while read m _; do   \/sbin\/modinfo -F filename \"$m\"; done &lt;\/proc\/modules | sed -nr \"s@^\/lib\/modules\/`uname -r`\/kernel\/drivers\/net(\/.*)?\/([^\/]+)\\.ko\\$@\\2@p\" &gt;&gt; \/etc\/initramfs-tools\/modules<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432 <code>\/etc\/initramfs-tools\/scripts\/<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0432 \u0431\u043e\u043d\u0434\u0438\u043d\u0433\u0435:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/initramfs-tools\/scripts\/init-premount\/00_bonding_init<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/sh -e PREREQS=\"\" case $1 in         prereqs) echo \"${PREREQS}\"; exit 0;; esac  echo \"Network interfaces loaded: \" echo `ls \/sys\/class\/net`  for x in $cmdline; do     case $x in     bondslaves=*)             bondslaves=\"${x#bondslaves=}\"             ;;     esac done  IFS=\",\" for x in $bondslaves; do     echo \"+$x\" &gt; \/sys\/class\/net\/bond0\/bonding\/slaves done<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043d\u0434\u0438\u043d\u0433-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/initramfs-tools\/scripts\/init-bottom\/iface_down<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/sh -e  PREREQS=\"\" case $1 in         prereqs) echo \"${PREREQS}\"; exit 0;; esac  if [ ! -d \/sys\/class\/net\/bond0 ]; then   exit 0 fi  echo \"Remove bonding interface...\"  for x in $cmdline; do     case $x in     bondslaves=*)             bondslaves=\"${x#bondslaves=}\"             ;;     esac done  IFS=\",\" for x in $bondslaves; do     echo \"-$x\" &gt; \/sys\/class\/net\/bond0\/bonding\/slaves done  echo \"-bond0\" &gt; \/sys\/class\/net\/bonding_masters<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0441\u0435\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">chmod +x \/etc\/initramfs-tools\/scripts\/init-premount\/00_bonding_init \/etc\/initramfs-tools\/scripts\/init-bottom\/iface_down<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0439\u0434\u0443\u0442 \u0432 \u0431\u043e\u043d\u0434\u0438\u043d\u0433 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430.<br \/>  \u0410\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u043f\u043e DHCP, \u0442.\u043a. \u0431\u043e\u043d\u0434\u0438\u043d\u0433 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 MAC, \u0447\u0442\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0440\u043e\u0443\u0442\u0435\u0440 \u0432\u044b\u0434\u0430\u0441\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 IP \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442 \u043f\u0440\u043e\u0431\u0440\u043e\u0441 \u043f\u043e\u0440\u0442\u043e\u0432.<br \/>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0431\u043e\u043d\u0434\u0438\u043d\u0433 <code>bond0<\/code> \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c NAS:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">sed -i \"s\/\\(GRUB_CMDLINE_LINUX_DEFAULT=\\)\\\"\\(.*\\)\\\"\/\\1\\\"\\2 $(echo -n ip=:::::bond0:dhcp bondslaves=$(sed -e 's\/ \/,\/' \/sys\/class\/net\/bond0\/bonding\/slaves))\\\"\/\" \/etc\/default\/grub<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0433 GRUB \u0438 \u043e\u0431\u0440\u0430\u0437 initramfs:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">update-grub update-initramfs -u -k $(uname -r)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451. \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432 initrmafs, \u043f\u0438\u043d\u0433\u0438 \u043d\u0430 IP NAS \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u041e\u0421 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0431\u043e\u043d\u0434\u0438\u043d\u0433\u0430 \u0432 Dracut \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0435\u0433\u0447\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <a href=\"https:\/\/github.com\/zfsonlinux\/dracut\/blob\/master\/modules.d\/40network\/parse-bond.sh\">\u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435<\/a>.<\/p>\n<p>  <\/p>\n<h1 id=\"ssh-server-v-initramfs\">SSH \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 initramfs<\/h1>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Dropbear SSH \u0432 initramfs:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">apt-get install dropbear-initramfs<\/code><\/pre>\n<p>  <\/p>\n<p>Dropbear SSH \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 initrmafs \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0438 \u043e\u043d \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043d\u0430 \u0440\u0430\u043d\u043d\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043d\u044f\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 IP \u0430\u0434\u0440\u0435\u0441\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043a\u043b\u044e\u0447 Dropbear \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 OpenSSH \u0438 \u0437\u0430\u043a\u0440\u043e\u0439\u0442\u0435 \u0435\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">\/usr\/lib\/dropbear\/dropbearconvert dropbear openssh \/etc\/dropbear\/dropbear_rsa_host_key \\   id_rsa dropbearkey -y -f \/etc\/dropbear\/dropbear_rsa_host_key | \\   grep \"^ssh-rsa \" &gt; id_rsa.pub ssh-keygen -p -f id_rsa<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447 <code>id_rsa<\/code> \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430. \u042f \u0431\u0443\u0434\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>~\/.ssh\/dropbear<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0412 <code>\/etc\/dropbear-initramfs\/authorized_keys<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043a\u0438 \u043a\u043b\u044e\u0447\u0430 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043a\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">echo 'no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command=\"\/bin\/cryptroot-unlock\"' $(cat id_rsa.pub) &gt;&gt; \/etc\/dropbear-initramfs\/authorized_keys<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0435 \u043e\u0431\u0451\u0440\u0442\u043a\u0438, \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, <code>\/bin\/cryptroot-unlock<\/code> \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c <code>\/etc\/dropbear-initramfs\/authorized_keys<\/code> \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435:<\/p>\n<p>  <\/p>\n<pre><code>no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command=\"\/bin\/cryptroot-unlock\" ssh-rsa AAAA...XDa root@nas<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0433 GRUB \u0438 \u043e\u0431\u0440\u0430\u0437 initramfs \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">update-grub update-initramfs -u -k $(uname -r) reboot<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0421 \u043c\u0430\u0448\u0438\u043d\u044b, \u043a\u0443\u0434\u0430 \u0432\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u044e\u0447<\/em> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a NAS \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code>$ ssh -i .ssh\/dropbear\/id_rsa_initram -o UserKnownHostsFile=.ssh\/dropbear\/known_hosts root@nas.NAS.cloudns.cc Enter passphrase for key '.ssh\/dropbear\/id_rsa_initram': X11 forwarding request failed on channel 0 Please unlock disk root_crypt1 (\/dev\/disk\/by-id\/ata-Samsung_SSD_850_PRO_256GB-part3):<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043e\u0431 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u043d\u043e \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0439\u0434\u0451\u0442. \u042d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 (\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043b\u0435\u0433\u043a\u043e, \u043d\u043e \u043e\u0431\u0451\u0440\u0442\u043a\u0438 \u0435\u0451 \u043d\u0435 \u043b\u0435\u0447\u0430\u0442).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/hamy.io\/post\/0005\/remote-unlocking-of-luks-encrypted-root-in-ubuntu-debian\">Remote unlocking of LUKS-encrypted root in Ubuntu\/Debian<\/a>.<\/li>\n<li><a href=\"https:\/\/help.ubuntu.ru\/wiki\/unlock_luks_ssh\">\u0420\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 SSH \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e ubuntu-server 12.04<\/a>.<\/li>\n<li><a href=\"https:\/\/stinkyparkia.wordpress.com\/2014\/10\/14\/remote-unlocking-luks-encrypted-lvm-using-dropbear-ssh-in-ubuntu-server-14-04-1-with-static-ipst\/\">Remote unlocking LUKS encrypted LVM using Dropbear SSH in Ubuntu Server 14.04.1<\/a>.<\/li>\n<li><a href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/unlock-full-encrypted-system-via-ssh\/\">Unlock full-encrypted system via SSH<\/a>.<\/li>\n<\/ul>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/419915\/\"> https:\/\/habr.com\/post\/419915\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419915\/\" class=\"post__text post__text-html js-mediator-article\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mc\/mz\/-h\/mcmz-h3bsxctbh1ka8wxdtdnvqs.png\"><\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u044f\u043a\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/habr.com\/post\/359344\">\u0412 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u043c NAS<\/a>, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043d\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044f \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u043d\u0438\u0436\u0430\u043b\u043e \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0431\u044b\u043b\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0439, \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u0438 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u0438\u0447\u0435\u0441\u0442\u0432\u043e: \u0437\u0430 \u0442\u0440\u0438 \u043c\u0435\u0441\u044f\u0446\u0430 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u0418\u0411\u041f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u043a\u0440\u0430\u0442\u043a\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0431\u043e\u0438 \u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043e\u0442 \u0431\u0430\u0442\u0430\u0440\u0435\u0439 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0441\u0430 (\u0445\u043e\u0442\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u2014 \u043e\u043a\u043e\u043b\u043e \u0447\u0430\u0441\u0430), \u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0430\u043a\u043e\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0435\u0437\u0434\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0433\u043e\u0440\u043e\u0434.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-288473","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288473"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288473\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}