{"id":156989,"date":"2012-11-01T12:53:03","date_gmt":"2012-11-01T08:53:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=156989"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=156989","title":{"rendered":"<span class=\"post_title\">\u0423\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043c\u043e\u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 luks \u0432 CentOS6 \u0447\u0435\u0440\u0435\u0437 ssh<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u043c\u043e\u0432, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=524727#c7\">\u00abMichael Scherer\u00bb \u0432 bagzilla redhat<\/a>, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a CentOS 6 x64. \u0421\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Initrd\">initramfs<\/a>. <a name=\"habracut\"><\/a><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/h4>\n<p>  \u0412 initramfs \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 dropbear, \u0435\u0433\u043e \u043d\u0435\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445, \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u2014 epel:<\/p>\n<pre><code class=\"bash\">rpm -Uhv http:\/\/download.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-7.noarch.rpm yum -y install dropbear <\/code><\/pre>\n<h4>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f initramfs<\/h4>\n<p>  \u0412 CentOS 6 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 initramfs \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430- dracut, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0430\u043f\u043a\u0443 \u0432 \/usr\/share\/dracut\/modules.d \u0441\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.  <\/p>\n<pre><code class=\"bash\">cd \/usr\/share\/dracut\/modules.d mkdir 40unlock cd 40unlock <\/code><\/pre>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u044f:  <\/p>\n<pre><code class=\"bash\">cat &gt; install &lt;&lt; 'EOF' #!\/bin\/bash  cat \/etc\/shadow|grep root &gt; ${moddir}\/shadow  dracut_install \/lib64\/libnss_compat.so.2  dracut_install \/lib64\/libnss_files.so.2  dracut_install \/lib64\/libnss_dns.so.2  inst_dir &quot;\/etc\/dropbear&quot;  inst &quot;${moddir}\/dropbear_rsa_host_key&quot; &quot;\/etc\/dropbear\/dropbear_rsa_host_key&quot;  inst_dir &quot;\/home&quot;  inst_dir &quot;\/home\/root&quot;  inst_dir &quot;\/home\/root\/.ssh&quot;  inst &quot;${moddir}\/.profile&quot; &quot;\/home\/root&quot;  [ -s &quot;${moddir}\/authorized_keys&quot; ] && inst &quot;${moddir}\/authorized_keys&quot; &quot;\/home\/root\/.ssh\/authorized_keys&quot;  inst &quot;\/etc\/localtime&quot;  inst &quot;${moddir}\/nsswitch.conf&quot; &quot;\/etc\/nsswitch.conf&quot;  inst &quot;\/etc\/resolv.conf&quot;  inst &quot;\/etc\/host.conf&quot;  inst &quot;\/etc\/hosts&quot;  inst &quot;${moddir}\/shadow&quot; &quot;\/etc\/shadow&quot;  inst &quot;${moddir}\/passwd&quot; &quot;\/etc\/passwd&quot;  inst &quot;${moddir}\/shells&quot; &quot;\/etc\/shells&quot;  inst &quot;${moddir}\/unlock&quot; &quot;\/bin\/unlock&quot;  inst_hook pre-trigger 01 &quot;$moddir\/remote-ssh.sh&quot;  inst_hook pre-pivot 01 &quot;$moddir\/clean.sh&quot;  dracut_install sed awk dropbear ifconfig route blkid cut killall true mkdir  dracut_install -o ps find grep less cat tac head tail false rmdir rm touch vi ping ssh scp lsmod EOF <\/code><\/pre>\n<p>  \u041e\u043d \u0431\u0435\u0440\u0435\u0442 \u0438\u0437 shadow \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c root, \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443, \u0442\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435 \u0432 \u044d\u0442\u0443 \u0436\u0435 \u043f\u0430\u043f\u043a\u0443 \u0444\u0430\u0439\u043b authorized_keys c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0451\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 600. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0424\u0430\u0439\u043b\u044b hosts, resolv.conf \u0438 host.conf \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435. \u0421\u0442\u0430\u0432\u044f\u0442\u0441\u044f 2 \u0445\u0443\u043a\u0430: \u043f\u0435\u0440\u0432\u044b\u0439(remote-ssh.sh) \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 dropbear \u0435\u0449\u0435 \u0434\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u0432\u0442\u043e\u0440\u043e\u0439(clean.sh) \u0443\u0431\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 dropbear \u043f\u0435\u0440\u0435\u0434 \u0441\u043c\u0435\u043d\u043e\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0444\u0441. \u0412 \u00abdracut_install -o\u00bb \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 initramfs \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u00ab\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438\u00bb:  <\/p>\n<pre><code class=\"bash\">cat &gt; check &lt;&lt; 'EOF' #!\/bin\/sh exit 0 EOF <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f dracut \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0439\u0442\u0435 \u043a\u043e\u0434 \u0432\u044b\u0445\u043e\u0434\u0430 \u043d\u0430 255, \u0430 \u0442\u0430\u043a \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u044f\u0434\u0440\u0430 \u043d\u043e\u0432\u044b\u0439 initramfs \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430:  <\/p>\n<pre><code class=\"bash\">cat &gt; installkernel &lt;&lt; 'EOF' #!\/bin\/bash instmods e1000 EOF <\/code><\/pre>\n<p>  \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u0432 initramfs, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b intel e1000, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439( \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>lspci -k<\/code> ).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043d\u0430\u0448\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b.<\/p>\n<pre><code class=\"bash\">echo 'root:x:0:0:root:\/home\/root:\/bin\/sh' &gt; passwd echo '\/bin\/sh' &gt; shells echo 'export PATH=\/sbin:\/usr\/sbin:$PATH' &gt;.profile dropbearkey -t rsa -f dropbear_rsa_host_key <\/code><\/pre>\n<p>  \u00ab\u0421\u043e\u0437\u0434\u0430\u0435\u043c\u00bb root \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u00ab\u0448\u0435\u043b\u043e\u0432\u00bb, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e PATH \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c rsa \u043a\u043b\u044e\u0447 \u0434\u043b\u044f dropbear.<\/p>\n<pre><code class=\"bash\">cat &gt;nsswitch.conf &lt;&lt; 'EOF' passwd:  files shadow:  files group:  files initgroups: files hosts:  files dns bootparams: files ethers:  files netmasks: files networks: files protocols: files rpc:  files services: files automount: files aliases: files EOF <\/code><\/pre>\n<p>  \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0440\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043a\u0430\u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c dns \u0438\u043c\u0435\u043d\u0430.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0434\u044a\u0435\u043c\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 dropbear:  <\/p>\n<pre><code class=\"bash\">cat &gt;remote-ssh.sh &lt;&lt; 'EOF' #!\/bin\/sh \/sbin\/modprobe e1000 \/sbin\/ifconfig lo 127.0.0.1\/8 \/sbin\/ifconfig lo up \/sbin\/ifconfig eth0 192.168.100.203\/24 \/sbin\/ifconfig eth0 up \/sbin\/route add default gw 192.168.100.1 \/bin\/mkdir -p \/var\/log \/usr\/sbin\/dropbear -E -m -p 2222 -a -K 600 &gt; \/var\/log\/lastlog EOF <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 modprobe \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b( \u0442\u043e\u0442 \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 installkernel ), \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0438\u043c\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043d\u0430 \u0441\u0432\u043e\u0438, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e ip \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 dhcp \u2014 \u0432 \u0441\u0440\u043a\u0440\u0438\u043f\u0442 install \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 dhclient \u0438 \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 dropbear:  <\/p>\n<pre><code class=\"bash\">cat &gt; clean.sh &lt;&lt; 'EOF' #!\/bin\/sh \/usr\/bin\/killall dropbear EOF <\/code><\/pre>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 luks \u0442\u043e\u043c\u043e\u0432, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445 \u0432\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u043e\u043b\u044f:  <\/p>\n<pre><code class=\"bash\">cat &gt; unlock &lt;&lt; 'EOF' if [ -f \/etc\/crypttab ] ; then sed '\/^$\/d;\/^#\/d' \/etc\/crypttab &gt; \/tmp\/crypttab n=1 line=&quot;`sed -n &quot;$n&quot;p \/tmp\/crypttab`&quot; while [ -n &quot;$line&quot; ]; do   name=&quot;`echo $line|awk '{ print $1 }'`&quot;   dev=&quot;`echo $line|awk '{ print $2 }'`&quot;   key=&quot;`echo $line|awk '{ print $3 }'`&quot;   if [ &quot;$key&quot; = &quot;none&quot; ]; then     luksname=&quot;$name&quot;     if [ &quot;${dev%%=*}&quot; = &quot;UUID&quot; ]; then       device=&quot;`blkid -t $dev|cut -d: -f1`&quot;     else       device=$dev     fi     echo &quot;Password [$device ($luksname)]:&quot;      while :;     do       cryptsetup luksOpen $device $luksname && break     done   fi   n=$((n+1))   line=&quot;`sed -n &quot;$n&quot;p \/tmp\/crypttab`&quot; done sed -i \/cryptsetup\/c\\ true \/pre-pivot\/* [ &quot;$1&quot; = &quot;-noexit&quot; ] && exit 0 killall plymouth killall cryptroot-ask fi exit 0 EOF <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u00ab\u0447\u0438\u0441\u0442\u044b\u0439\u00bb crypttab \u0431\u0435\u0437 \u0437\u0430\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0437\u0430\u0442\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0442\u043e\u043c\u0430 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u0435\u043d \u043f\u0430\u0440\u043e\u043b\u044c. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u043e\u0434\u0443\u043b\u044c luks \u043e\u0442 dracut \u043f\u0435\u0440\u0435\u0434 \u0441\u043c\u0435\u043d\u043e\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0444\u0441 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 luks \u0442\u043e\u043c\u0430, \u0442\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u0438\u043a\u043f\u0442\u044b \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432 \/pre-pivot, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e. \u0415\u0441\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>-noexit<\/code>, \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0431\u0438\u0442\u044b \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 initramfs \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b. \u0414\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <br \/>  <code>killall cryptroot-ask<\/code><\/p>\n<p>  \u0420\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u0430 \u043d\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432 <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=524727#c7\">bugzilla<\/a> \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 luks \u0442\u043e\u043c\u0430( \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442 root ) \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u043c\u0435\u043d\u044b \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0444\u0441, \u0442\u043e\u0438\u0441\u0442\u044c dropbear \u0443 \u043d\u0430\u0441 \u0435\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0441\u0435\u0442\u044c(\u0435\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u0445\u0443\u043a \u043d\u0430 \u0435\u0433\u043e \u0443\u0431\u0438\u0435\u043d\u0438\u0435), \u043d\u043e \u043d\u0438\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043d\u0435\u043c \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 \/usr\/share\/dracut\/modules.d\/40unlock \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:  <\/p>\n<pre><code class=\"bash\">[root@crypt 40unlock]# ls -al \u0438\u0442\u043e\u0433\u043e 56 drwxr-xr-x.  2 root root 4096 \u041e\u043a\u0442 31 17:36 . drwxr-xr-x. 32 root root 4096 \u041e\u043a\u0442 31 17:35 .. -rwxr-xr-x.  1 root root   17 \u041e\u043a\u0442 31 17:35 check -rwxr-xr-x.  1 root root   36 \u041e\u043a\u0442 31 17:36 clean.sh -rw-------.  1 root root  427 \u041e\u043a\u0442 31 17:36 dropbear_rsa_host_key -rwxr-xr-x.  1 root root 1066 \u041e\u043a\u0442 31 17:35 install -rwxr-xr-x.  1 root root   27 \u041e\u043a\u0442 31 17:36 installkernel -rw-r--r--.  1 root root  222 \u041e\u043a\u0442 31 17:36 nsswitch.conf -rw-r--r--.  1 root root   35 \u041e\u043a\u0442 31 17:36 passwd -rw-r--r--.  1 root root   34 \u041e\u043a\u0442 31 17:36 .profile -rwxr-xr-x.  1 root root  270 \u041e\u043a\u0442 31 17:36 remote-ssh.sh -rw-r--r--.  1 root root    8 \u041e\u043a\u0442 31 17:36 shells -rwxr-xr-x.  1 root root  740 \u041e\u043a\u0442 31 17:36 unlock <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c initramfs.   <\/p>\n<pre><code class=\"bash\">chmod a+x check clean.sh install installkernel remote-ssh.sh unlock dracut -f  <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0439\u0442\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 ssh \u0438 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 luks \u0442\u043e\u043c\u0430 \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0435 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:  <\/p>\n<pre><code class=\"bash\">unlock <\/code><\/pre>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b:<\/b><br \/>  \u042d\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u0430 \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0449\u0438\u043d\u0435 \u0438 \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f virtio \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 udev \u043e\u043d\u0430 \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c\u0441\u044f. \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0431\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0445\u0443\u043a pre-trigger \u043f\u043e\u0432\u0435\u0441\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442- \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 udev, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0435\u0435\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c luks( \u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 udev- \u043f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 luks \u0442\u043e\u043c\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430) \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0435\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 remote-ssh.sh.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"bash\">SUBSYSTEM!=&quot;block&quot;, GOTO=&quot;luks_end&quot; ACTION!=&quot;add|change&quot;, GOTO=&quot;luks_end&quot; ENV{ID_FS_TYPE}==&quot;crypto_LUKS&quot;, RUN+=&quot;\/bin\/remote-ssh.sh&quot; LABEL=&quot;luks_end&quot; <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044f \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b.<\/p>\n<h4>\u0421\u0441\u044b\u043b\u043a\u0438 \u043f\u043e \u0442\u0435\u043c\u0435:<\/h4>\n<p>  <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=524727\">Dracut + encrypted root + networking<\/a><br \/>  <a href=\"http:\/\/www.kernel.org\/pub\/linux\/utils\/boot\/dracut\/dracut.html\">Dracut manual<\/a><\/p>\n<p>  PS: \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c- \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/156989\/\"> http:\/\/habrahabr.ru\/post\/156989\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u043c\u043e\u0432, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=524727#c7\">\u00abMichael Scherer\u00bb \u0432 bagzilla redhat<\/a>, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a CentOS 6 x64. \u0421\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Initrd\">initramfs<\/a>. <\/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-156989","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/156989","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=156989"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/156989\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}