<?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>Tim Bowler &#187; ssh</title>
	<atom:link href="http://timothybowler.com/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://timothybowler.com</link>
	<description>Certified Scrum Master &#124; Certified Scrum Practitioner &#124; Agile Coach &#124; Agile Practitioner</description>
	<lastBuildDate>Sat, 19 Dec 2009 16:14:31 +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>SSH and automated backups</title>
		<link>http://timothybowler.com/2009/01/20/ssh-and-automated-backup/</link>
		<comments>http://timothybowler.com/2009/01/20/ssh-and-automated-backup/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 13:52:20 +0000</pubDate>
		<dc:creator>Tim Bowler</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://timothybowler.com/?p=91</guid>
		<description><![CDATA[One of the key tools for ssh automation is keychain, which is pretty much available in most flavors of linux. Its usually not installed by default, therefore using your package manager install &#8216;keychain&#8217;
Ubuntu users:
$sudo apt-get install keychain
After its install, you set it up by entering the keychain command followed by your private key (not the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the key tools for ssh automation is keychain, which is pretty much available in most flavors of linux. Its usually not installed by default, therefore using your package manager install &#8216;keychain&#8217;</p>
<p>Ubuntu users:</p>
<pre class="brush: bash; light: true; toolbar: true;">$sudo apt-get install keychain</pre>
<p>After its install, you set it up by entering the keychain command followed by your private key (not the public key).</p>
<pre class="brush: bash; light: true; toolbar: true;">$ keychain ~/.ssh/id_rsa
KeyChain 2.6.6; http://www.gentoo.org/proj/en/keychain/ Copyright 2002-2004
Gentoo Foundation; Distributed under the GPL&lt;/pre&gt;
* Initializing /home/timmy/.keychain/hostname-sh file...
* Initializing /home/timmy/.keychain/hostname-csh file...
* Initializing /home/timmy/.keychain/hostname-fish file...
* Starting ssh-agent
* Adding 1 ssh key(s)...
Enter passphrase for /home/timmy/.ssh/id_rsa:
Identity added: /home/timmy/.ssh/id_rsa (/home/timmy/.ssh/id_rsa)</pre>
<p>Keychain then creates three files which correspond to various shell environments. As I am using bash, the file I will be referencing will be  /home/timmy/.keychain/hostname-sh.</p>
<pre class="brush: bash; light: true; toolbar: true;">$ source ~/.keychain/hostname-sh</pre>
<p>To make sure everything is fine run the following to make sure the the environment is in fact set up:</p>
<pre class="brush: bash; light: true; toolbar: true;">$ env | grep SSH_A
SSH_AGENT_PID=9607
SSH_AUTH_SOCK=/tmp/ssh-bMoLeb9606/agent.9606</pre>
<p>Of course you will want this to happen automatically on login so add the following to your ~/.bashrc</p>
<pre class="brush: bash; light: true; toolbar: true;">keychain ~/.ssh/id_rsa
source ~/.keychain/hostname-sh</pre>
<p>The last step is to add the following line to your backup script (including the .)</p>
<pre class="brush: bash; light: true; toolbar: true;">. /home/timmy/.keychain/hostname-sh</pre>
<p>Backup Scripts<br />
Ill only mention the two methods that i use.<br />
1. scp: To copy files from one location to another<br />
2. rsync: To sync a remote location to local location</p>
<p><span id="more-91"></span></p>
<p><strong>SCP</strong></p>
<pre class="brush: bash; light: true; toolbar: true;">. /home/timmy/.keychain/hostname-sh
scp -r /home/timmy/Server_Backups/web/* root@192.168.0.1:/var/backup/web</pre>
<p><strong>Rsync</strong></p>
<pre class="brush: bash; light: true; toolbar: true;">. /home/timmy/.keychain/hostname-sh
rsync -rzvhlc --delete -e &quot;ssh -p 22 -i /home/timmy/.ssh/id_rsa -o 'BatchMode yes'&quot;
root@hostname:/var/www/vhosts/vhostname/httpd/ home/timmy/Server_Backups/web/</pre>
<p>After that you should not get the error:</p>
<pre class="brush: bash; light: true; toolbar: true;">Permission denied, please try again.
Received disconnect from 192.168.0.10: 2: Too many authentication failures for root
lost connection</pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ftimothybowler.com%2F2009%2F01%2F20%2Fssh-and-automated-backup%2F';
  addthis_title  = 'SSH+and+automated+backups';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://timothybowler.com/2009/01/20/ssh-and-automated-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH security</title>
		<link>http://timothybowler.com/2008/08/10/ssh-security/</link>
		<comments>http://timothybowler.com/2008/08/10/ssh-security/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 22:26:22 +0000</pubDate>
		<dc:creator>Tim Bowler</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh attacks]]></category>
		<category><![CDATA[ssh configure]]></category>
		<category><![CDATA[sshd]]></category>

		<guid isPermaLink="false">http://timothybowler.com/2008/08/10/ssh-security/</guid>
		<description><![CDATA[Over the last few weeks the server logs, especially /var/log/messages seems to be filled with consistent ssh dictionary attacks. Of course this cannot continue, so what do you do to prevent it?
Well there are a few things:

1. Setup the firewall to handle them
2. Installing deny hosts
3. Configure your ssh daemon properly
4. Set up proper accounts [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few weeks the server logs, especially /var/log/messages seems to be filled with consistent ssh dictionary attacks. Of course this cannot continue, so what do you do to prevent it?</p>
<p>Well there are a few things:</p>
<p><span id="more-42"></span></p>
<p>1. Setup the firewall to handle them</p>
<p>2. Installing deny hosts</p>
<p>3. Configure your ssh daemon properly</p>
<p>4. Set up proper accounts for people</p>
<p>The methods that I deploy are points 1, 3 and 4.</p>
<p><strong>Configuring SSH </strong></p>
<p>In the sshd_conf do the following:</p>
<p>-  change the port number: <strong>port 9999</strong></p>
<p>- Allow no password auth: <strong>PasswordAuthentication no</strong></p>
<p>- Allow public key auth: <strong>PubkeyAuthentication yes</strong></p>
<p>- Only allow user accounts that belong to a group: <strong>AllowGroups groupName</strong></p>
<p>By setting the above you have place a lot of restrictions on the who can access your server using ssh.</p>
<p><strong>Configure your firewall iptables in linux<br />
</strong></p>
<pre class="brush: bash; light: true; toolbar: true;">iptables -N SSH_CHECK
iptables -A INPUT -p tcp --dport 9999 -m state --state NEW -j SSH_CHECK
iptables -A SSH_CHECK -m recent --set --name SSH
iptables -A SSH_CHECK -m recent --update --minutes 60 --hitcount 4 --name SSH -j DROP</pre>
<p>Finally  the last thing is to configure the user accounts that can access the server. It is strongly recommended to add the users to the sudousers if they require any specialist privileges.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ftimothybowler.com%2F2008%2F08%2F10%2Fssh-security%2F';
  addthis_title  = 'SSH+security';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://timothybowler.com/2008/08/10/ssh-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
