Advertise with Googlier.com Allan Feid - OpenSolaris https://allanfeid.com/category/tags/opensolaris en Central login management with OpenLDAP https://allanfeid.com/content/central-login-management-openldap <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Over the weekend I spent some time learning how to configure OpenLDAP to provide a central login server at home. This is pretty useful since I was tired of either syncing UID/GID's across servers or setting directories to 777 on my NFSv4 server. I chose Fedora 12 as my OS for the server, and will show how easy it is to configure authentication on both Fedora and OpenSolaris.</p> <h2>Some information about the network</h2> <p>I'll give you a quick overview of how the network looks from home.</p> <ul><li><strong>DNS:</strong> ns1.crazy.lan (172.16.1.3)</li> <li><strong>LDAP:</strong> ldap1.crazy.lan (10.10.1.1)</li> <li><strong>Client 1:</strong> test.crazy.lan (10.10.2.1)</li> <li><strong>Client 2:</strong> virt.crazy.lan (192.168.1.8)</li> </ul><p>I'm not going to go over the importance of DNS (both forward and reverse lookups should work!) right now, but you will save yourself plenty of headaches by making sure DNS is setup properly on your network.</p> <h2>Basic configurations</h2> <h3>Install the needed software!</h3> <p>For Fedora 12, installing OpenLDAP is easy:</p> <pre><code># yum install -y openldap* </code></pre><p>This will get you everything you need to get started.</p> <p>There are a few things you need to change in order to really start using OpenLDAP. Everything is all in one file <cite>slapd.conf</cite>. Prior to editing the file, you'll want to generate a password to use in this configuration.</p> <pre><code># slappasswd New password: Re-enter new password: {SSHA}fFVfwsztHn+xuQPjN/q/urdNC+V0G+dW </code></pre><p>Copy the new hash as you will need to paste it into the configuration file. Add or modify the following in <em>/etc/openldap/ldap.conf</em>:</p> <pre><code>suffix "dc=crazy,dc=lan" rootdn "cn=Manager,dc=crazy,dc=lan" rootpw {SSHA}fFVfwsztHn+xuQPjN/q/urdNC+V0G+dW # ACL's to use loglevel acl stats access to dn.base="" by * read access to dn.base="cn=Subschema" by * read access to * by self write by * read by anonymous auth </code></pre><p>That's all you need there for a basic configuration. This will not be using TLS/SSL, I will cover that in a later post. It's always good to start with the basics so that you can spend more time learning the protocol. Once you've gotten that down hardening a service is easy.</p> <p>Now we just need to finish up and start the service. Since <cite>slapd.conf</cite> is deprecated in favor of the <cite>slapd.d/</cite> directory, we can use the configuration file to generate the appropriate directory structure. The huge advantage of this style is <strong>dynamic backend configuration changes</strong>. Yes, that means persistent dynamic changes. No more restarting your directory server to <a href="http://blog.suretecsystems.com/archives/163-OpenLDAP-Quick-Tips-Change-loglevels-on-the-fly!.html" title="Change loglevels on the fly!">make changes to things such as your logging level</a>.</p> <pre><code># cd /etc/openldap # rm -rf slapd.d # mkdir slapd.d # slaptest -f slapd.conf -F slapd.d # chown -R ldap:ldap slapd.d # chkconfig slapd on # service slapd start </code></pre><p>You can test for functionality by running the following:</p> <pre><code>ldapsearch -x -h localhost </code></pre><p>If all went well you will see some output and no errors.</p> <h3>Configure rsyslog for logging</h3> <p>If you're not using Fedora, or rsyslog, you'll want to lookup the specifics for your logging daemon's configuration. OpenLDAP sends it's logging output to the local4 log facility. For rsyslog, just add the following line to <cite>/etc/rsyslog.conf</cite>:</p> <pre><code>local4.* -/var/log/ldap </code></pre><p>Then restart your logging service.</p> <pre><code>service rsyslog restart </code></pre><h3>Importing some data to LDAP</h3> <p>The LDIF formatted file is where things start to get a little bit tricky. Don't worry about it so much as there are plenty of good GUI clients for LDAP, but we do need to get a few things imported.</p> <pre><code># crazy.lan dn: dc=crazy,dc=lan objectClass: dcObject objectClass: organization o: Crazy Organization dc: crazy # Manager, crazy.lan dn: cn=Manager,dc=crazy,dc=lan objectClass: organizationalRole cn: manager # People, crazy.lan dn: ou=People,dc=crazy,dc=lan objectClass: organizationalUnit ou: People # Group, crazy.lan dn: ou=Group,dc=crazy,dc=lan objectClass: organizationalUnit ou: Group # users, Group, crazy.lan dn: cn=users,ou=Group,dc=crazy,dc=lan objectClass: posixGroup objectClass: top cn: users gidNumber: 2000 # myaccount, People, crazy.lan dn: uid=myaccount,ou=People,dc=crazy,dc=lan uid: myaccount objectClass: account objectClass: posixAccount objectClass: top objectClass: shadowAccount gidNumber: 2000 uidNumber: 3000 homeDirectory: /home/myaccount loginShell: /bin/bash userPassword: {SSHA}cc696ZrGCPmgx0/CD2zGJrMqR3tb8iMk cn: Allan Feid </code></pre><p>I saved the above as <cite>import.ldif</cite>. You will probably want to generate a new password with <code class="prettyprint">slappaswd</code> to use with the userPassword section above. Now to import, it all I have to do is this:</p> <pre><code>ldapadd -f import.ldif -D "cn=Manager,dc=crazy,dc=lan" -W </code></pre><p>This will prompt you for your <cite>rootdn</cite> password that you created earlier using <code class="prettyprint">slappasswd</code>. Now you have the following basic hierarchy configured:</p> <ul><li><strong>Base Domain:</strong> crazy.lan <ul><li><strong>Organizational Unit:</strong> People <ul><li><strong>User:</strong> myaccount</li> </ul></li> <li><strong>Organizational Unit:</strong> Group <ul><li><strong>Group:</strong> users</li> </ul></li> </ul></li> </ul><p>User accounts will go into the People OU, and group accounts will be assigned the Group OU. This is a pretty standard configuration as the <cite>pam_ldap</cite> plugin will look in these OU's later for user/group information.</p> <h2>Client configuration</h2> <h3>Fedora 12</h3> <p>Redhat has really made this easier than it used to be. Their <code class="prettyprint">authconfig</code> command is pretty straight forward, the following commands will get you the <code class="prettyprint">nss_ldap</code>, <code class="prettyprint">pam_ldap</code> and ldap utility commands on your client:</p> <pre><code># yum install -y openldap-clients # authconfig --enableldap \ --enableldapauth \ --disablenis \ --enablecache \ --ldapserver=ldap1.crazy.lan \ --ldapbasedn=dc=crazy,dc=lan \ --updateall </code></pre><p>That's it. You will now see the <cite>myaccount</cite> user if you run <code class="prettyprint">getent</code>.</p> <pre><code># getent passwd |grep myaccount myaccount:x:3000:2000:Allan Feid:/home/myaccount:/bin/bash </code></pre><h3>OpenSolaris</h3> <p>This should also work for plain Solaris, but I prefer OpenSolaris and haven't tested on Solaris 10. This, just like Redhat, is very easy to configure, but does require one extra step. The <code class="prettyprint">ldapclient</code> command by default copies <code class="prettyprint">/etc/nsswitch.ldap</code> to <code class="prettyprint">/etc/nsswitch.conf</code>. Which is fine, but the ldap nsswich configuration by, by default, uses ldap for hostname lookups. This is probably not desirable in most cases as that's what we use DNS for. So just change the following lines in <code class="prettyprint">/etc/nsswitch.ldap</code>:</p> <pre><code>hosts: files dns ipnodes: files dns </code></pre><p>Then just a simple command will get you up and running:</p> <pre><code># ldapclient -v manual -a defaultSearchBase=dc=crazy,dc=lan \ -a domainName=crazy.lan \ -a defaultServerList=ldap1.crazy.lan # getent passwd |grep myaccount myaccount:x:3000:2000::/home/myaccount:/bin/bas </code></pre><h3>General Configuration for client's using pam_ldap/nss_ldap</h3> <p>If you aren't using Fedora or OpenSolaris, anything that uses pam_ldap/nss_ldap can be configured pretty easily. The main configuration file for these two is <code class="prettyprint">/etc/ldap.conf</code>. All you need is to make sure you have the following lines:</p> <pre><code>base dc=crazy,dc=lan uri ldap://ldap1.crazy.lan/ </code></pre><p>Then you will have to configure nss by changing the following in <code class="prettyprint">/etc/nsswitch.conf</code>:</p> <pre><code>passwd: files ldap shadow: files ldap group: files ldap </code></pre><p>You will also need to modify your PAM configuration. Generally you will want to edit <code class="prettyprint">/etc/pam.d/system-auth</code> but this may very from OS to OS. Always check with the documentation!</p> <pre><code>auth sufficient pam_ldap.so use_first_pass </code></pre><h2>Use ADS, make your life easier!</h2> <p>I highly recommend <a href="http://directory.apache.org/studio/" title="Apache Directory Studio">Apache Directory Studio</a> as a great LDAP client. It is cross platform (java based) and having a GUI for ldap sometimes just makes more sense as you get to visualize your hierarchy easily. Setup a new connection and login as <code class="prettyprint">cn=Manager,dc=crazy,dc=lan</code> using your <cite>rootdn</cite> password. You can now easily create a template user to be copied for new users, add new groups, add OU's, etc all from a comfortable GUI.</p> <p>In upcoming posts, I plan on covering enabling TLS encryption, and eventually working on Kerberos integration with LDAP for a <cite>true</cite> Single SIgn-On (SSO) environment. If all goes well I'll share how I got it all working.</p> </div></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss"><h2 class="field-label">Tags:&nbsp;</h2><ul class="field-items"><li class="field-item even"><a href="/category/tags/linux" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Linux</a></li><li class="field-item odd"><a href="/category/tags/opensolaris" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">OpenSolaris</a></li><li class="field-item even"><a href="/category/tags/sysadmin" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">sysadmin</a></li><li class="field-item odd"><a href="/category/tags/fedora" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Fedora</a></li><li class="field-item even"><a href="/category/tags/openldap" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">OpenLDAP</a></li><li class="field-item odd"><a href="/category/tags/ldap" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">ldap</a></li><li class="field-item even"><a href="/category/tags/authentication" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">authentication</a></li></ul></section> Sun, 28 Mar 2010 17:18:58 +0000 Allan Feid 63 at https://allanfeid.com Serving iSCSI targets from your zpool https://allanfeid.com/content/serving-iscsi-targets-your-zpool <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even" property="content:encoded"><p>If you've already got an OpenSolaris based NFS server, you may be interested in serving iSCSI targets. For me, this is incredibly useful with the right network configurations and a machine running KVM based virtual machines.</p> <!--break--><h2>What is iSCSI?</h2> <p>If you already know, no point in reading this section but there are some important key things to know when dealing with iSCSI. All this is, is a way of executing SCSI commands over the wire (ethernet, fibre, whatever). You are sharing space at the block level and this is important to realize before you start sharing iSCSI targets amongst multiple hosts. You WILL come into issues doing this without a cluster aware filesystem such as <a href="http://www.redhat.com/gfs/" title="Global File System">GFS</a>, or a volume management system such as <a href="http://www.redhat.com/docs/manuals/csgfs/browse/rh-cms-desc-ov-en/s1-clvm-overview.html" title="Clustered Logical Volume Management">cLVM</a>.</p> <p>iSCSI of course has its own terminology which you should be aware of. The iSCSI "server" (also referred to as portal) presents targets, and the iSCSI "client" is called the initiator. The initiator searches for available iSCSI targets on your iSCSI portal. I suggest taking a quick glace at the <a href="http://en.wikipedia.org/wiki/ISCSI" title="Wikipedia: iSCSI">wikipedia artcle on iSCSI</a> if you want more technical knowledge, but as long as you understand these basics you will be running iSCSI in no time. </p> <h2>Give me some targets!</h2> <p>Before you can start assigning targets you need to enable the iscsitgt service.</p> <pre>$ pfexec svcadm enable iscsitgt</pre><p> Now that we have that out of the way, we can create a zvol of 100G to serve over iSCSI as follows:</p> <pre> $ pfexec zfs create tank/targets $ pfexec zfs set shareiscsi=on tank/targets $ pfexec zfs create -V 100G $ iscsitadm list target Target: tank/targets/lun0 iSCSI Name: iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416 Connections: 1 tank/targets/lun0 </pre><p> You now have iSCSI targets being presented from your server. Accessing these all depends on your client's OS, so you may be interested in looking at <a href="/content/connect-iscsi-targets-linux" title="Connect iSCSI targets on Linux">using iscsi targets on Linux</a>. Depending on your network configuration, you may need to limit these targets from being accessible on all interfaces. I highly recommend limiting this as things will get confusing if you are serving the same iSCSI targets from multiple interfaces.</p> <h2>Restricting access</h2> <p>To limit what network interface a target group listens on:</p> <pre> $ pfexec iscsitadm create tpgt 1 $ pfexec iscsitadm modify tpgt -i 10.20.0.2 1 $ iscsitadm list tpgt -v 1 TPGT: 1 IP Address: 10.20.0.2 $ iscsitadm modify target -p 1 tank/targets/lun0 </pre><p> This creates target group 1, then modifies that group to only listen on 10.20.0.2 and finally apply group 1 to the target <code>tank/targets/lun0</code>. There is also a basic authentication method available called CHAP but in reality your iSCSI network should be completely isolated from other traffic. I do not see it as necessary for the authentication and that just tends to complicate things.</p> </div></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss"><h2 class="field-label">Tags:&nbsp;</h2><ul class="field-items"><li class="field-item even"><a href="/category/tags/zfs" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">zfs</a></li><li class="field-item odd"><a href="/category/tags/opensolaris" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">OpenSolaris</a></li><li class="field-item even"><a href="/category/tags/sysadmin" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">sysadmin</a></li><li class="field-item odd"><a href="/category/tags/iscsi" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">iscsi</a></li></ul></section> Mon, 01 Mar 2010 18:41:48 +0000 Allan Feid 57 at https://allanfeid.com Ultimate File Server: OpenSolaris and ZFS https://allanfeid.com/content/ultimate-file-server-opensolaris-and-zfs <div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even" property="content:encoded"><p>When picking out a solution for your central file server, there is of course many options. None of them quite stack up to the ease of administration and redundancy, out of the box, as OpenSolaris and ZFS provide. With ZFS you can build cheap storage arrays with disks of varying size and different levels of redundancy. For this setup I'm going to go with a basic raidz configuration using 4x 1TB SATA drives.</p> <!--break--><h2>A quick note on ZFS</h2> <p>For those of you aware of ZFS, you can probably go ahead and skip this section, but for those of you that don't I'll give a quick description of how things work in the ZFS world. Instead of partitions and volumes, ZFS gives you pools and datasets. The <code>zpool</code> command gives you control of your pools and <code>zfs</code> command gives you control over your datasets. There is <cite>almost</cite> no limit to the amount of ZFS datasets you can create and you shouldn't be scared to create new ones for almost everything. Each dataset created allows you to perform individual snapshots, set different share options (iscsi, nfs, etc), apply quotas, compression, and even level of redundancy for those extra important files. These datasets work in a hierarchical format, meaning that any subsets will inherit from their master. Take a look at the below as an example.</p> <pre> $ pfexec zfs create tank/shares $ pfexec zfs set sharenfs=on tank/shares $ pfexec zfs create tank/shares/music </pre><p> The dataset, tank/shares/music, will inherit the <code>sharenfs=on</code> option applied to tank/shares. So it makes sense to create different levels of datasets. Put like datasets inside the same master dataset to easily control options for them all. </p> <h2>Get your ZFS raidz on</h2> <p>Depending on the value of your data you may wish to consider raidz2 but I'm going with the basic single parity raidz which allows for better write performance and is similar to a RAID-5 configuration. For more information on raidz you may wish to check out <a href="http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide#RAIDZ_Configuration_Requirements_and_Recommendations" title="ZFS Best Practices">these RAIDZ configuration requirements and recommendations</a>.</p> <pre> $ pfexec zpool create raidz tank c7d1 c8d0 c8d1 c10d1 $ zpool status tank pool: tank state: ONLINE status: The pool is formatted using an older on-disk format. The pool can still be used, but some features are unavailable. action: Upgrade the pool using 'zpool upgrade'. Once this is done, the pool will no longer be accessible on older software versions. scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 c7d1 ONLINE 0 0 0 c8d0 ONLINE 0 0 0 c8d1 ONLINE 0 0 0 c10d1 ONLINE 0 0 0 errors: No known data errors </pre><p> <cite>Pro tip: <code>iostat -En</code> will give you a list of all your disks.</cite></p> <p>The first line creates the raidz pool called "tank" using the four disks (c7d1, c8d0, c8d1, c10d1). The second one gives you a nice overview of health for your new pool. It will also tell you if you should upgrade your zpool to a newer version, which as you can see, needs to be done on my storage pool. I created it awhile ago and haven't had the time to upgrade just yet. The man pages for <code>zpool</code> and <code>zfs</code> provide a wealth of information and are good way to learn the ins and outs of maintaining a ZFS system. </p> <h2>NFS on ZFS</h2> <p>This is ridiculously easy to setup. There's no need for touching the exports file, especially since Solaris does not use <code>/etc/exports</code> as other Linux and BSD derivatives do. The following will set you up with a basic export to the 192.168.1.0/24 network and provide read/write access.</p> <pre> $ pfexec zfs create -p tank/share/movies $ pfexec zfs set sharenfs='rw=192.168.1.0/24' tank/share $ zfs get -r sharenfs tank/share NAME PROPERTY VALUE SOURCE tank/share sharenfs rw=192.168.1.0/24 local tank/share/movies sharenfs rw=192.168.1.0/24 inherited from tank/share </pre><p> For those of you wondering, <code>-r</code> means recursive and can be applied in many different <code>zfs</code> sub-commands. If you need to disable root squashing (not recommended) you can do it per individual IP as follows:</p> <pre>$ pfexec zfs set sharenfs='rw=192.168.1.0/24,root=192.168.1.30/32' tank/share</pre><p> This will only disable root squashing on 192.168.1.30. One final example, what if you need read only to a different network?</p> <pre>$ pfexec zfs set sharenfs='rw=192.168.1.0/24,root=192.168.1.30/32,ro=10.0.0.0/8' tank/share</pre><h2>Final notes</h2> <p>The real beauty of ZFS is that there is so much control over your file system. At first it may come off as confusing, but stick with it and you will appreciate an OpenSolaris file server over any Linux, *BSD, or Windows solution. To take this a step further, check out <a href="/content/serving-iscsi-targets-your-zpool" title="Serving iSCSI from your zpool">serving up iSCSI targets from ZFS</a>, and with the proper network configuration, you can use these targets for KVM virtualization.</p> </div></div></div><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above view-mode-rss"><h2 class="field-label">Tags:&nbsp;</h2><ul class="field-items"><li class="field-item even"><a href="/category/tags/zfs" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">zfs</a></li><li class="field-item odd"><a href="/category/tags/opensolaris" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">OpenSolaris</a></li><li class="field-item even"><a href="/category/tags/nfs" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">nfs</a></li><li class="field-item odd"><a href="/category/tags/sysadmin" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">sysadmin</a></li></ul></section> Mon, 01 Mar 2010 18:20:38 +0000 Allan Feid 56 at https://allanfeid.com