<?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>lioks&#039; &#187; Security</title>
	<atom:link href="http://lioks.buffout.org/?feed=rss2&#038;tag=security" rel="self" type="application/rss+xml" />
	<link>http://lioks.buffout.org</link>
	<description>FreeBSD tutorials &#38; tips for beginners</description>
	<lastBuildDate>Tue, 01 Dec 2009 14:58:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Enabling and securing sshd in FreeBSD</title>
		<link>http://lioks.buffout.org/?p=18</link>
		<comments>http://lioks.buffout.org/?p=18#comments</comments>
		<pubDate>Mon, 02 Nov 2009 13:30:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD Tutorials]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.aimxhaisse.com/lioks/?p=18</guid>
		<description><![CDATA[sshd is the Secure Shell Daemon and allows an user to gain a remote shell on a foreign machine.
Unlike telnet, it allows one to exchange data on a secure way over the internet/a private network.
Although it&#8217;s often configured for simple password authentication, it can also be set up for a stronger security mechanism by using [...]]]></description>
			<content:encoded><![CDATA[<p>sshd is the Secure Shell Daemon and allows an user to gain a remote shell on a foreign machine.<br />
Unlike telnet, it allows one to exchange data on a <strong>secure</strong> way over the internet/a private network.<br />
Although it&#8217;s often configured for simple password authentication, it can also be set up for a stronger security mechanism by using RSA/DSA keypairs.</p>
<p>First you need to generate your clients personnal keypair using <code>ssh-keygen</code>:<br />
<code><br />
% ssh-keygen<br />
</code><br />
After asking you a passphrase for these keys they are placed by default in <code>~/.ssh/</code>:<br />
- <code>~/.ssh/id_rsa.pub</code> is your public key and can be used by anyone to encrypt data<br />
- <code>~/.ssh/id_rsa</code> is your private key and is needed to decrypt data encrypted with the public key</p>
<p>Now we can configure sshd on the machine you want to gain remote access.<br />
All these modifications must be made on <code>/etc/ssh/sshd_config</code>:<br />
<code><br />
PasswordAuthentication no<br />
</code><br />
This should be set to no, since we want RSA key + passphrase authentication.</p>
<p><code><br />
PermitEmptyPasswords no<br />
</code><br />
If you want to use password authentication instead of public keys,  for obvious reasons, you REALLY should set this to no&#8230;</p>
<p><code><br />
ChallengeResponseAuthentication no<br />
</code><br />
This will disable FreeBSD built-in PAM authentication (but not password-based authentication).</p>
<p><code><br />
PermitRootLogin no<br />
</code><br />
It&#8217;s a really a bad habit to log as root on a machine, especially over ssh because you want to be able to log/audit user&#8217;s activity.<br />
A better way is to give some people the privileges they need using groups or login classes and/or sudo.</p>
<p><code><br />
Protocol 2<br />
</code><br />
You must restrict connections to SSHv2 because SSHv1 is now considered obsolete due to MITM vulnerabilities.</p>
<p><code><br />
X11Forwarding no<br />
</code><br />
Since I don&#8217;t need to forward X11 traffic, I like to disable it because it can make the client vulnerable to X11 attacks.<br />
If this is a concern to you, more informations can be found in sshd_config(5) and ssh_config(5) manpages.</p>
<p><code><br />
AllowUsers ...<br />
AllowGroups ...<br />
DenyUsers ...<br />
DenyGoups ...<br />
</code><br />
Last but not least, these powerful options allow you to manually specify who can log in or not by User/Group names.<br />
If you plan to accept very few ssh connections, I strongly recommand you to use these options. Additional security is always welcome&#8230;<br />
These options are processed in this order: DenyUsers, AllowUsers, DenyGroups, AllowGroups.</p>
<p>Now simply copy the public keys (id_rsa.pub, remember ?) of your clients in the authorized_keys file, by default it should be <code>~/.ssh/authorized_keys</code>, ~ being the home directory of the user they want to log as.<br />
Then add the following line to <code>/etc/rc.conf</code> to enable sshd at startup and reboot your host machine:<br />
<code><br />
sshd_enable="YES"<br />
</code></p>
<p>Your clients can now remotely get a shell on your machine, but they must possess the private key associated to the public key in <code>authorized_keys</code> and the passphrase, needless to say that it&#8217;s way more secure than simple password authentication.<br />
One more thing about rsa/dsa keys, only give them if you are sure of the identity of the receiver and please, by more secure way than mail ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://lioks.buffout.org/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
