{"id":1242,"date":"2017-04-07T18:57:01","date_gmt":"2017-04-07T17:57:01","guid":{"rendered":"http:\/\/diablo.craem.net\/?p=1242"},"modified":"2017-04-07T18:57:01","modified_gmt":"2017-04-07T17:57:01","slug":"automatizar-anadir-varias-maquinas-debian-al-ldap","status":"publish","type":"post","link":"https:\/\/diablo.craem.net\/?p=1242","title":{"rendered":"Automatizar a\u00f1adir varias m\u00e1quinas debian al ldap"},"content":{"rendered":"<p>Esta vez, ten\u00ed\u00ada que automatizar la entrada anterior y a\u00f1adir varias m\u00e1quinas al ldap para login.<\/p>\n<p>Como no me hac\u00eda especial ilusi\u00f3n modificar todos los ficheros a mano, tenemos al amigo bash + sed.<\/p>\n<p>al lio:<\/p>\n<p><code><br \/>\n#!\/bin\/bash<\/code><\/p>\n<p><code><code><\/code><\/code><\/p>\n<p># ########################<br \/># ### by craem ###########<br \/># ########################<br \/># ########################<\/p>\n<p><code><code><\/code><\/code><\/p>\n<p>function instala_paquetes(){<br \/>echo \u00ab&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;\u00ab<br \/>echo \u00abaptitude -y install libnss-ldap libpam-ldap ldap-utils sudo \u00ab<br \/>aptitude -y install libnss-ldap libpam-ldap ldap-utils sudo<br \/>}<\/p>\n<p><code><code><\/code><\/code><\/p>\n<p>function modifica_ficheros(){<br \/>echo \u00ab&#8212; modificamos fichero nsswitch.conf &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u00ab<br \/>sed -ie &#8216;s\/compat\/ldap compat\/g&#8217; \/etc\/nsswitch.conf<br \/>echo \u00ab&#8212; modificamos el fichero common-session &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u00ab<br \/>echo \u00absession required pam_mkhomedir.so skel=\/etc\/skel umask=0022\u00bb &gt;&gt; \/etc\/pam.d\/common-session<br \/>echo \u00ab&#8212; reiniciamos el servicio nscd &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u00ab<br \/>\/etc\/init.d\/nscd restart<br \/>echo \u00ab&#8212; modificamos el sudoers &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u00ab<br \/>echo \u00ab%admin_users ALL=(ALL) ALL\u00bb &gt;&gt; \/etc\/sudoers<br \/>echo \u00ab&#8212; modificamos el fichero common-auth &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u00ab<br \/>echo \u00abauth required pam_access.so\u00bb &gt;&gt; \/etc\/pam.d\/common-auth<br \/>echo \u00ab&#8212; modificamos el access.conf &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;\u00ab<br \/>echo \u00ab-:ALL EXCEPT root (admin_users):ALL EXCEPT LOCAL\u00bb &gt;&gt; \/etc\/security\/access.conf<br \/>echo \u00ab&#8212; modificamos el fichero ldap.conf &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;\u00ab<br \/>sed -ie &#8216;s\/#BASE dc=example,dc=com\/BASE dc=craem,dc=net\/g&#8217; \/etc\/ldap\/ldap.conf<br \/>echo \u00ab&#8212; modificamos el ldap.conf &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u00ab<br \/>echo \u00abURI ldap:\/\/ldap.craem.net\u00bb &gt;&gt; \/etc\/ldap\/ldap.conf<br \/>echo \u00ab&#8212; fin del script &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;\u00ab<\/p>\n<p><code><code><\/code><\/code><\/p>\n<p>}<br \/>instala_paquetes<br \/>modifica_ficheros<\/p>\n<p><code>\n<\/code><\/p>\n<p><code><\/code><\/p>\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Esta vez, ten\u00ed\u00ada que automatizar la entrada anterior y a\u00f1adir varias m\u00e1quinas al ldap para login. Como no me hac\u00eda especial ilusi\u00f3n modificar todos los ficheros a mano, tenemos al amigo bash + sed. al lio: #!\/bin\/bash # ######################### ### by craem ############ ######################### ######################## function instala_paquetes(){echo \u00ab&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;\u00abecho \u00abaptitude -y install libnss-ldap libpam-ldap ldap-utils sudo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[58,100],"class_list":["post-1242","post","type-post","status-publish","format-standard","hentry","category-linux","tag-debian","tag-ldap"],"_links":{"self":[{"href":"https:\/\/diablo.craem.net\/index.php?rest_route=\/wp\/v2\/posts\/1242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diablo.craem.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diablo.craem.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diablo.craem.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diablo.craem.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1242"}],"version-history":[{"count":0,"href":"https:\/\/diablo.craem.net\/index.php?rest_route=\/wp\/v2\/posts\/1242\/revisions"}],"wp:attachment":[{"href":"https:\/\/diablo.craem.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diablo.craem.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diablo.craem.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}