<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>~#nixy &#187; FreeBSD</title>
	<atom:link href="http://nixy.dk/category/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://nixy.dk</link>
	<description>Nix is sexy</description>
	<lastBuildDate>Fri, 16 Oct 2009 09:04:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Serious issue: Change loader logo in FreeBSD 6+</title>
		<link>http://nixy.dk/2008/03/20/serious-issue-change-loader-logo-in-freebsd-6/</link>
		<comments>http://nixy.dk/2008/03/20/serious-issue-change-loader-logo-in-freebsd-6/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 18:00:30 +0000</pubDate>
		<dc:creator>Rada</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[appearance]]></category>
		<category><![CDATA[beastie]]></category>
		<category><![CDATA[logo]]></category>

		<guid isPermaLink="false">http://nixy.dk/2008/03/20/serious-issue-change-loader-logo-in-freebsd-6/</guid>
		<description><![CDATA[Now, ever since the new FreeBSD logo was concieved, we have had to deal with the cumbersome &#8220;Free BSD&#8221; ascii art on our boot screens. But not anymore! In one of my general fits of boredom, I went into /boot/ and had a look through the files. Always remember to familiarize yourself with your operating [...]]]></description>
			<content:encoded><![CDATA[<p>Now, ever since the new FreeBSD logo was concieved, we have had to deal with the cumbersome &#8220;Free BSD&#8221; ascii art on our boot screens.</p>
<p>But not anymore! In one of my general fits of boredom, I went into <code>/boot/</code> and had a look through the files. Always remember to familiarize yourself with your operating system, even if you&#8217;ve been running it for ages.</p>
<p>In <code>/boot/beastie.4th</code>, there&#8217;s some ascii art. One looks like a colored beastie, the other like a monotone beastie, and a third is the ASCII art text.  Now, shouldn&#8217;t there be some configuration switch to change this behaviour as it fits us? Sure thing!</p>
<p>Just grep <code>/boot/defaults/loader.conf</code> after &#8220;logo&#8221;. <code>grep logo /boot/defaults/loader.conf</code>, and voilá!</p>
<pre>[alive@p0rnteddy /boot]$ grep logo defaults/loader.conf
#loader_logo="fbsdbw"           # Desired logo: fbsdbw, beastiebw, beastie, none</pre>
<p>See, you can even remove the logo altogether, or hack the <code>beastie.4th</code> file to include your own. Just remember to make sure it fits on the screen &#8211; I don&#8217;t even know what would happen if it didn&#8217;t; Haven&#8217;t been stupid enough to test.</p>
<p>Anyway, the colored beastie, while a nice feature, requires tweaking &#8211; as it looks ugly to my eyes. Open up your <code>/boot/loader.conf</code> and write <code>loader_logo="beastiebw"</code>.</p>
<p>Reboot your system and enjoy the sight.</p>
]]></content:encoded>
			<wfw:commentRss>http://nixy.dk/2008/03/20/serious-issue-change-loader-logo-in-freebsd-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using daemontools (supervise) on FreeBSD</title>
		<link>http://nixy.dk/2007/10/22/using-daemontools-supervise-on-freebsd/</link>
		<comments>http://nixy.dk/2007/10/22/using-daemontools-supervise-on-freebsd/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 21:20:34 +0000</pubDate>
		<dc:creator>Rada</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[supervise]]></category>
		<category><![CDATA[daemontools]]></category>
		<category><![CDATA[svscan]]></category>

		<guid isPermaLink="false">http://nixy.dk/2007/10/22/using-daemontools-supervise-on-freebsd/</guid>
		<description><![CDATA[What is daemontools? From the daemontools website: daemontools is a collection of tools for managing UNIX services. supervise monitors a service. It starts the service and restarts the service if it dies. Setting up a new service is easy: all supervise needs is a directory with a run script that runs the service. At first [...]]]></description>
			<content:encoded><![CDATA[<p>What is daemontools?</p>
<p>From the <a href="http://cr.yp.to/daemontools.html" title="daemontools">daemontools website</a>:</p>
<blockquote><p> daemontools is a collection of tools for managing UNIX services.</p>
<p><tt>supervise</tt> monitors a service. It starts the service and restarts the service if it dies. Setting up a new service is easy: all <tt>supervise</tt> needs is a directory with a <tt>run</tt> script that runs the service.</p></blockquote>
<p>At first when I was introduced to this tool at work, I thought &#8220;What a typical Linux-admin. FreeBSD&#8217;s rc. system is superior.&#8221; Despite my personal preferences, whatever software is used at work is what I have to use and learn to use, too. After getting a little more familiar with supervise, and installing it on a FreeBSD server, I was finally convinced that this may also have a place on FreeBSD machines.</p>
<p>Have you ever needed to know that a process is 100% sure to be running no matter what? Well, some of our applications need that extra little safety net, and you might too. Just right of the bat I can mention things like httpd, sshd, <a href="http://nixy.dk/2007/10/12/denyhosts-on-freebsd-62/" title="DenyHosts on FreeBSD 6.2">denyhosts</a>, and syslog(-ng). While the theoretical risk of these applications crashing randomly and still being able to run again without any direct editing of some configuration file seems to be very low, in a production environment where loads are extremely high and all processes are pushed into a stage where their theoretical load-handling capacity is on the edge with what has practically been tested, this may happen to you &#8211; and you can&#8217;t afford the service being down until you figure out a way to fix it permanently.</p>
<p>Either way, if some application crashes in a recoverable manner, it&#8217;s most likely that either 1) supervise is still running and will try to revive the process or 2) your box is so broken, it doesn&#8217;t even matter that supervise is still running. It&#8217;s all about that extra little factor of reliability.</p>
<p>Convinced? Here&#8217;s the walkthrough:<br />
install <code>sysutils/daemontools</code>. When the configure page pops up, make sure to let it install the manpages, but leave out SIGQ12 if you don&#8217;t know what it is or don&#8217;t need it. After installing, edit the file <code>/usr/local/etc/rc.d/svscan.sh</code>. For some odd reason, daemontools doesn&#8217;t have a separate configuration file, so you&#8217;ll have to edit all options right here. The comments say that you should edit <code>/etc/rc.conf.d/svscan</code>, but that is probably some oddball Linux-specific thing, and no such directory exists in FreeBSD.  Have a quick look through the first lines of the file, and edit any settings that are specific to your setup. Either way, uncomment the (MIN|MAX)* lines, and the ulimits.  The next important thing to note, is the svscan_servicedir variable. Unless you have a really good reason to edit this, don&#8217;t.</p>
<p>Before starting svscan, we need to create the services dir and a service for it to start. If you didn&#8217;t edit the servicedir variable, you should just <code>mkdir /var/service</code>. Okay, what now?<br />
Imagine a scenario where you have a development server with two NICs. One internal, one external. On the external NIC, you want to be running with &#8220;PermitRootLogin no&#8221;, because any sane sysadmin wouldn&#8217;t allow root logins from random people on the internet. On the other hand, you have twenty developers who need to share this server &#8211; And you want to let them create their own accounts on the server as they wish, without disturbing anybody else, so you also want to run PermitRootLogin set to &#8220;yes&#8221; on the internal NIC.<br />
This might sound crazy, because obviously, it&#8217;s impossible to have the two at the same time. You have to only pick one configuration or make a very dirty hack, right? Incorrect. We can do this cleanly with supervise.</p>
<p>This one is one of the more complicated setups, just so you&#8217;ll have an idea of which conveniences supervise can provide, other than auto-starting crashed daemons.</p>
<p><code>cd /var/service &amp;&amp; mkdir sshdint sshdext; \<br />
cp /etc/ssh/sshd_config sshint/; cp /etc/ssh/sshd_config sshext/</code><br />
What we&#8217;ve done now, is to create to service directories for each instance of the ssh daemon we want to run, and copy over the system-wide configuration file. Now go edit the sshd_config in sshdint to allow root logins and listen on the internal IP, and the one in sshdext to deny them and listen on the external IP.</p>
<p>sshdint/sshd_config:</p>
<pre># You can only have one sshd instance listening on any one given IP.
ListenAddress [internal ip]

# For the internal IP, enable root logins.
PermitRootLogin yes

# It's important to have a different pid file for each daemon.
# Otherwise the universe will collapse.
PidFile /var/run/sshdint.pid</pre>
<p>sshdext/sshd_config:<br />
<code>ListenAddress [external ip]<br />
PermitRootLogin no<br />
PidFile /var/run/sshdext.pid</code></p>
<p>Edit other configuration settings as you wish. For example, it could maybe be a good idea to have the external sshd listen to a non-default port if you don&#8217;t want to run DenyHosts. But that&#8217;s beyond the scope of this article. You&#8217;ll be able to experiment with that by yourself once you&#8217;re done with this article.</p>
<p>Now, create the <code>run</code> scripts for each sshd.</p>
<p>Create <code>/var/service/(sshdint|sshdext)/run</code>, and edit them.</p>
<p>sshdint/run:<br />
<code>#!/bin/sh<br />
/usr/sbin/sshd -Df /var/service/sshdint/sshd_config</code></p>
<p>If you don&#8217;t specify the -D flag, sshd will detach and supervise will think that it&#8217;s down &#8211; so it&#8217;ll try to start the service again, for eternity.<br />
The other run file should contain the exact same content, except that &#8220;sshdint&#8221; should be &#8220;sshdext&#8221; in the path to the configuration file. Now, just <code>chmod u+x run</code> in each directory.</p>
<p>We&#8217;re almost done! For this next part, make sure you have direct access in the form of a screen and keyboard, as it&#8217;s very likely that you did a misconfiguration somewhere and that your sshd&#8217;s will all die.<br />
- Disable sshd in /etc/rc.conf<br />
- Enable svscan in /etc/rc.conf (svscan_enable=&#8221;YES&#8221;)</p>
<p><strong>Warning</strong>: Before proceeding, quadruple-double-triple-check that you&#8217;ve written everything correctly, that all the hard-coded paths exist, and that every little configuration is correct. You should even parse every script that you know will soon run in your head three times, before this next step. I can&#8217;t stress this enough. If you don&#8217;t have direct access to the box you&#8217;re playing with, either through a keyboard and screen or through a KVM swith, you&#8217;re 90% likely to lose all possible ways of interacting with this server once you execute the next step. Consider yourself warned. I don&#8217;t want any complaints in my comments about misconfigurations on your part.</p>
<p>- Run <code>/usr/local/etc/rc.d/svscan start</code><br />
If it starts correctly, it will now try to spawn two instances of sshd,  but they&#8217;ll both fail at starting up because you&#8217;ve got one system-wide sshd running, which is bound to all network interfaces on your system by default. If everything seems to be right, you should now see svscan running (<code>ps ax|grep svscan</code>) and you should get a lot of errors in <code>/var/log/messages</code> about sshd&#8217;s not being able to bind to any address. Now you can:<br />
- Stop sshd. <code>/etc/rc.d/sshd stop</code>.</p>
<p>You should now have two working sshd&#8217;s each listening on their own port. If you still get error messages in your messages log, you can either <code>killall -9 sshd</code> or just cleanly reboot the system.</p>
<p>Right now it&#8217;s late and my girlfriend is getting grumpy, so I&#8217;ll just leave this article open-ended (for now), but following things are to be aware of:<br />
- I think the sshd&#8217;s are trying to generate new certificates each time they are restarted (Although I&#8217;m absolutely not sure). This can easily be fixed by assigning each sshd it&#8217;s own set of certificates and making the appropriate changes in each sshd configuration file.<br />
- I wrote this article as I was doing the dual-sshd setup for the first time in my life, not even knowing if it will eventually work, so a lot of errors may occur, and I probably forgot to write a lot of important notes and things to consider.<br />
- You will not be able to ssh to localhost after this, because you no longer have a sshd listening on the loopback interface. Optionally, you could run an extra instance of sshd if you really need to ssh to localhost.<br />
- The dual-sshd setup is also achievable without daemontools, but not as cleanly as here.</p>
<p>Enjoy your new supervise setup :)</p>
]]></content:encoded>
			<wfw:commentRss>http://nixy.dk/2007/10/22/using-daemontools-supervise-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>DenyHosts on FreeBSD 6.2</title>
		<link>http://nixy.dk/2007/10/12/denyhosts-on-freebsd-62/</link>
		<comments>http://nixy.dk/2007/10/12/denyhosts-on-freebsd-62/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 22:05:41 +0000</pubDate>
		<dc:creator>Rada</dc:creator>
				<category><![CDATA[DenyHosts]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[sshd]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://nixy.dk/2007/10/12/denyhosts-on-freebsd-62/</guid>
		<description><![CDATA[If you run a nix server for a little while, you&#8217;ll notice that bots will try to gain illegitimate access to your server through ssh. While this unsettles a lot of people, there&#8217;s really nothing to worry about as long as you don&#8217;t permit root logins (Many Linux distributions allow direct root login via ssh [...]]]></description>
			<content:encoded><![CDATA[<p>If you run a nix server for a little while, you&#8217;ll notice that bots will try to gain illegitimate access to your server through ssh. While this unsettles a lot of people, there&#8217;s really nothing to worry about as long as you don&#8217;t permit root logins (Many Linux distributions allow direct root login via ssh by default) and have a strong password policy.</p>
<p>Nonetheless, taking just an extra measure of security is a good idea, and this is where <a href="http://denyhosts.sourceforge.net/" title="DenyHosts" target="_blank">DenyHosts</a> comes into the picture. DenyHosts is a small Python script which makes password-guessing on your OpenSSH deployments virtually impossible, by allowing only a limited number of login attempts to your sshd. After a set  number of tries, DenyHosts simply denies the given IP further attempts. What&#8217;s even cooler about DenyHosts, is that the most recent version (2.0) allows you to benefit from over <a href="http://stats.denyhosts.net/stats.html" title="DenyHosts Statistical Summary" target="_blank">23.400 other peoples ban lists</a>, thus meaning you&#8217;re saving yourself a lot of worrying about those pesky login attempts. An added bonus is that you&#8217;ll save yourself a few kB&#8217;s of network traffic and a few CPU cycles by straight-out denying any previous offenders a connection to your server. :)</p>
<p>Other people might just want to save themselves the trouble, and move their sshd to a <a href="http://www.freebsddiary.org/ssh-higher-port.php" title="Putting sshd on a higher port">different port</a>. I believe that this solution is just security through obscurity, and is dangerous in the way that it gives a false sense of security to the admin. I disagree with that kind of solution, as you might notice if you look at the <a href="http://www.freebsddiary.org/phorum/read.php?f=3&amp;i=1492&amp;t=1492&amp;article_id=611" title="Security through obscurity">comments</a> the article in question has generated. (Please notice that even though I disagree with his method of avoiding sshd bots, I deeply respect the work that Dan is putting into The FreeBSD Diary.)</p>
<p>DenyHosts depends on Python, which you have to make sure you want to have on your server. Python isn&#8217;t such a bad thing to have &#8211; but porting DenyHosts to sh would certainly reduce the amount of CPU cycles needed, and of course, remove Python as a dependency for those who don&#8217;t want to bloat their server.</p>
<p>So let&#8217;s get started, shall we?</p>
<p>First, make sure that you&#8217;ve got the updated ports tree (Use portsnap) and install the <code>security/denyhosts</code> port. If you&#8217;ve already got Python, this should only take a few seconds, as nothing needs to be compiled.</p>
<p>Once installed, DenyHosts gives you a lot of info about how to configure it, but I&#8217;ll repeat it just in case.</p>
<p>Open /etc/rc.conf, add the lines<br />
<code>denyhosts_enable="YES"<br />
syslogd_flags="-c"</code><br />
The first line ensures that DenyHosts starts at boot time. The second line makes sure that syslogd does not group repeated log messages, so that they appear as &#8220;Last line repeated 23234 times&#8221; &#8211; This makes it possible for DenyHosts to actually count how many login attempts any given hosts has made.</p>
<p>Now edit /etc/hosts.allow and add the lines<br />
<code>sshd :  /etc/hosts.deniedssh : deny<br />
sshd : ALL : allow</code><br />
This will ensure that the hosts.allow mechanism in FreeBSD denies connections to your sshd from any of the hosts listed in hosts.deniedssh, and allows all other connections. The last line parsed is authoritative, so in theory if you add an IP to the block list in hosts.deniedssh, and allow the same IP later in the parsing process, the host will be allowed to connect.</p>
<p>Before we go further, we need to make sure that the hosts.deniedssh file exists and has the correct permissions:<br />
<code>touch hosts.deniedssh<br />
chmod 644 hosts.deniedssh<br />
chown root:wheel hosts.deniedssh</code></p>
<p>Almost there. For good measure, we should probably edit the <code>/usr/local/etc/denyhosts.conf</code>. If it&#8217;s not there, copy over denyhosts.conf-dist to denyhosts.conf, and fire up your favorite editor.<br />
Make sure to read every single line of the sample configuration file, and adjust the settings to whatever fits your system and preferences. The most vital options here are the:</p>
<ul>
<li><code>SECURE_LOG</code>, which should be /var/log/auth.log, just in case the &#8220;Mandrake, FreeBSD or OpenBSD&#8221; comment right above it confused you</li>
<li><code>HOSTS_DENY</code>, should be set to /etc/hosts.deniedssh just in case you forgot which file you were creating a second ago</li>
</ul>
<p>All of the timing and recurrency options are quite sane defaults, so I&#8217;d recommend you not to touch them unless you either know what you&#8217;re doing, or if you&#8217;re very picky about these kinds of things.</p>
<p>Now you should have a nicely working DenyHosts installation, but wait, remember the 23.400 people who are contributing to the DenyHosts lists? Why not be a part of this amazing network? All it requires, is that you enable the synchronization feature. Just uncomment the <code>SYNC_SERVER</code> variable, and synchronization will work fine.</p>
<p>The reason why synchronization isn&#8217;t enabled by default even though it&#8217;s the optimal setting for the vast majority of installations, is because synchronization poses a <em>theoretical</em> security risk, and a <em>theoretical</em> privacy risk.</p>
<p>The security risk is &#8211; as I said &#8211; purely theoretical, as if some evil hacker was to be pissed off by all these people who are not responding to his ssh-bots, and should decide to hack the denyhosts synchronization server, he could send malicious code to all synchronizing DenyHosts clients. Remember, though, that this risk is as improbable as the sky falling down on our heads, and that anybody can buy a license to use the synchronization server for use in their private network. You could also reverse engineer the synchronization protocol that DenyHosts uses and make your own synchronization server &#8211; But then again, this entire paragraph consists solely of theoretical possibilities.</p>
<p>All that&#8217;s left to done is to restart the system (To make sure syslogd starts with the -c flag) and to make sure DenyHosts has started at boot time.<br />
<code>ps -ax|grep  denyhosts</code><br />
If you enabled synchronization, you can also watch as DenyHosts fills up the hosts.deniedssh file with lots and lots of persistent sshd-brute forcing zombies. Dare to cat it?</p>
<p>Enjoy your new non-obscurely secured sshd!</p>
]]></content:encoded>
			<wfw:commentRss>http://nixy.dk/2007/10/12/denyhosts-on-freebsd-62/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->