<?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>Kevin Deldycke &#187; SSH</title> <atom:link href="http://kevin.deldycke.com/tag/ssh/feed/" rel="self" type="application/rss+xml" /><link>http://kevin.deldycke.com</link> <description>Free software engineer &#38; wannabe videomaker</description> <lastBuildDate>Fri, 03 Feb 2012 19:08:27 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Configuring Fail2Ban on Debian Squeeze</title><link>http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/</link> <comments>http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/#comments</comments> <pubDate>Tue, 21 Jun 2011 10:25:16 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[Exim]]></category> <category><![CDATA[fail2ban]]></category> <category><![CDATA[security]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3236</guid> <description><![CDATA[This always start with a package installation: Then I simply create a local configuration file where I&#8217;ll put all my custom config: Here is the content of that file: While adjusting Fail2Ban, I was surprised by how sensitive this software &#8230; <a href="http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This always start with a package installation:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install fail2ban
</pre><p>Then I simply create a local configuration file where I&#8217;ll put all my custom config:</p><pre class="brush: bash; title: ; notranslate">
$ touch /etc/fail2ban/jail.local
</pre><p>Here is the content of that file:</p><pre class="brush: plain; title: ; notranslate">
[DEFAULT]
# Do not filter connexion from my apartment and from the server itself
ignoreip  = 127.0.0.1 88.123.123.123 91.123.123.123
# Ban for a week
bantime   = 604800
maxretry  = 3
destemail = kevin@deldycke.com
banaction = iptables-allports
action    = %(action_mwl)s

[ssh]
enabled  = true
port     = 22
maxretry = 2

[ssh-ddos]
enabled = true
port     = 22

[apache]
# Apache basic auth
enabled   = true
maxretry  = 3
# Ban for 1 hour
bantime   = 3600

[apache-noscript]
enabled = true

[apache-overflows]
enabled = true

[apache-badbots]
enabled  = true
filter   = apache-badbots
port     = http,https
action   = iptables-allports
logpath  = /var/log/apache*/*access.log
maxretry = 1

[apache-nohome]
enabled  = true
filter   = apache-nohome
port     = http,https
action   = iptables-allports
logpath  = /var/log/apache*/*access.log
maxretry = 1

[exim]
enabled  = true
filter   = exim
port     = smtp,ssmtp
action   = iptables-allports
logpath  = /var/log/exim*/rejectlog
maxretry = 1

[exim-relay]
enabled  = true
filter   = exim-relay
port     = smtp,ssmtp
action   = iptables-allports
logpath  = /var/log/exim*/rejectlog
maxretry = 1
</pre><p>While adjusting Fail2Ban, I was surprised by how sensitive this software is. It can just refuse to start without any notice in the log or on the command line. Even if its <code>log_level</code> variable is set to <code>4</code> (= <code>DEBUG</code>) in <code>/etc/fail2ban/fail2ban.conf</code>.</p><p>In such a case, a sure way to find the culprit is to use a brute force debugging method: first set all the <code>enabled</code> variable of your <code>jail.local</code>&#8216;s sections to <code>false</code>. Then activate one section after another until Fail2Ban refuse to restart.</p><p>For me, the problem was that I forgot to add my custom <code>exim-relay</code> filter to Fail2Ban. So I fixed my issue by creating an empty file at <code>/etc/fail2ban/filter.d/exim-relay.conf</code> in which I pasted the following content:</p><pre class="brush: plain; title: ; notranslate">
# Based on default exim.conf filter by Cyril Jaquier
# Real life exemaple:
# 2009-07-02 08:16:42 H=118-167-129-21.dynamic.hinet.net (91.121.198.84) [118.167.129.21] F=&lt;titieueue@hotmail.com&gt; rejected RCPT &lt;s2288@mail2000.com.tw&gt;: relay not permitted

[Definition]

# Option:  failregex
# Notes.:  regex to match use of my exim mail server as a relay it does not
#          allow.
# Values:  TEXT
#
failregex = \[&lt;HOST&gt;\] .*(?:relay not permitted)

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
</pre><p>Speaking of custom filters, here is one to filter DFind scans (file located at <code>/etc/fail2ban/filter.d/apache-w00tw00t.conf</code>):</p><pre class="brush: plain; title: ; notranslate">
# Based on http://howflow.com/tricks/block_w00tw00t_scan_hosts_with_fail2ban
# Real life exemaple:
# [Sat Jun 27 16:43:08 2009] [error] [client 94.23.57.77] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

[Definition]

# Option:  failregex
# Notes.:  regex to match the w00tw00t scan messages in the logfile.
# Values:  TEXT
failregex = ^.*\[client &lt;HOST&gt;\].*w00tw00t\.at\.ISC\.SANS\.DFind.*

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
ignoreregex =
</pre><p>And here is the corresponding section from my <code>jail.local</code> file:</p><pre class="brush: plain; title: ; notranslate">
[apache-w00tw00t]
enabled  = true
filter   = apache-w00tw00t
action   = iptables-allports
logpath  = /var/log/apache*/*error.log
maxretry = 1
</pre>]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>My PuTTY profile template</title><link>http://kevin.deldycke.com/2010/04/putty-profile-template/</link> <comments>http://kevin.deldycke.com/2010/04/putty-profile-template/#comments</comments> <pubDate>Mon, 19 Apr 2010 21:49:40 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[PuTTY]]></category> <category><![CDATA[shell]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[Template]]></category> <category><![CDATA[terminal]]></category> <category><![CDATA[windows]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=1301</guid> <description><![CDATA[Inspired by a recent friend&#8217;s post about an annoying PuTTY behavior (fix included), here is my template for PuTTY profiles. It&#8217;s just a slightly modified version of Ilya Grigorik&#8217;s &#8220;Desert&#8221; color theme, with some tweaks that suit my needs.]]></description> <content:encoded><![CDATA[<p><a href="http://kevin.deldycke.com/wp-content/uploads/2010/04/putty-template-preview.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/04/putty-template-preview-150x150.png" alt="" title="putty-template-preview" width="150" height="150" class="alignleft size-thumbnail wp-image-1307" /></a> Inspired by a recent friend&#8217;s post about an <a href="http://www.think-underground.com/post/2010/04/13/Supprimer-le-comportement-%C3%A9trange-du-pav%C3%A9-num%C3%A9rique-dans-Putty">annoying PuTTY behavior (fix included)</a>, here is <a href="http://kevin.deldycke.com/static/documents/putty-template.reg">my template for PuTTY profiles</a>.</p><p>It&#8217;s just a slightly modified version of <a href="http://www.igvita.com/2008/04/14/custom-putty-color-themes/">Ilya Grigorik&#8217;s &#8220;Desert&#8221; color theme</a>, with some tweaks that suit my needs.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2010/04/putty-profile-template/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>OpenSSH commands</title><link>http://kevin.deldycke.com/2010/03/openssh-commands/</link> <comments>http://kevin.deldycke.com/2010/03/openssh-commands/#comments</comments> <pubDate>Fri, 26 Mar 2010 10:29:01 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[Computer networking]]></category> <category><![CDATA[find]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[openssh]]></category> <category><![CDATA[proxy]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[scp]]></category> <category><![CDATA[shell]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[tunnel]]></category> <category><![CDATA[xargs]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=1252</guid> <description><![CDATA[Here is the syntax that makes scp support spaces (source): Copy a bunch of files to a remote server (or how to use find with scp): Redirect local 8081 port to proxy.company.com:8080 via a SSH tunnel passing through the authorized-server.company.com &#8230; <a href="http://kevin.deldycke.com/2010/03/openssh-commands/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<ul><li>Here is the syntax that makes <code>scp</code> support spaces (<a href="http://rasterweb.net/raster/2005/01/27/scp-and-spaces/">source</a>):<pre class="brush: bash; title: ; notranslate">
scp foo.com:&quot;/home/fubar/some\ folder/file.txt&quot; ./
</pre></li><li>Copy a bunch of files to a remote server (or how to use <code>find</code> with <code>scp</code>):<pre class="brush: bash; title: ; notranslate">
find /var/log/ -iname &quot;*.log&quot; -type f | xargs -i scp '{}' kevin@myserver:/media/backup/logs/
</pre></li><li>Redirect local <code>8081</code> port to <code>proxy.company.com:8080</code> via a SSH tunnel passing through the <code>authorized-server.company.com</code> machine:<pre class="brush: bash; title: ; notranslate">
ssh -T -N -C -L 8081:proxy.company.com:8080 kevin@authorized-server.company.com
</pre></li><li>Use <code>rsync</code> over different SSH port (<a href="http://lists.samba.org/archive/rsync/2001-November/000495.html">source</a>):<pre class="brush: bash; title: ; notranslate">
rsync --progress -vrae 'ssh -p 8022' /home/user/docs/ bill@server:/home/user/docs/
</pre></li></ul> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2010/03/openssh-commands/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Fuse and sshfs on MacOSX Leopard</title><link>http://kevin.deldycke.com/2009/09/fuse-sshfs-macosx-leopard/</link> <comments>http://kevin.deldycke.com/2009/09/fuse-sshfs-macosx-leopard/#comments</comments> <pubDate>Mon, 07 Sep 2009 19:11:03 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Apple]]></category> <category><![CDATA[automount]]></category> <category><![CDATA[fuse]]></category> <category><![CDATA[KDE]]></category> <category><![CDATA[leopard]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Mac]]></category> <category><![CDATA[Mac OS X]]></category> <category><![CDATA[mount]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[sftp]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[sshfs]]></category> <category><![CDATA[system]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=817</guid> <description><![CDATA[I&#8217;m used to access distant machine&#8217;s file systems via ssh. My favorite environment, KDE, makes things easy thanks to the support of sftp:// URLs via a kio_slave. MacOSX is not as friendly and don&#8217;t have any built-in mechanism of that &#8230; <a href="http://kevin.deldycke.com/2009/09/fuse-sshfs-macosx-leopard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;m used to access distant machine&#8217;s file systems via ssh. My favorite environment, <a href="http://www.kde.org">KDE</a>, makes things easy thanks to the support of <code><a href="http://wikipedia.org/wiki/SSH_file_transfer_protocol">sftp</a>://</code> URLs via a <a href="http://wikipedia.org/wiki/KIO">kio_slave</a>. MacOSX is not as friendly and don&#8217;t have any built-in mechanism of that kind.</p><p>To get similar features in Leopard, we have to rely on <a href="http://code.google.com/p/macfuse/">MacFuse</a> and <a href="http://fuse.sourceforge.net/sshfs.html">sshfs</a>. I&#8217;ll explain here how I&#8217;ve installed these components on <a href="http://www.amazon.com/gp/product/B000FK88JK/ref=as_li_tf_tl?ie=UTF8&#038;tag=kevideld-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399381&#038;creativeASIN=B000FK88JK">MacOSX 10.5</a>.<img src="http://www.assoc-amazon.com/e/ir?t=kevideld-20&#038;l=as2&#038;o=1&#038;a=B000FK88JK&#038;camp=217145&#038;creative=399381" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p><p><a href="http://kevin.deldycke.com/wp-content/uploads/2009/09/MacFUSE_Banner.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2009/09/MacFUSE_Banner-300x86.png" alt="MacFUSE_Banner" title="MacFUSE_Banner" width="300" height="86" class="aligncenter size-medium wp-image-834" /></a></p><p>First, <a href="http://code.google.com/p/macfuse/downloads/list">download the latest MacFuse dmg</a> and install it. FYI, the version I&#8217;ve got was MacFuse 2.0.3,2.</p><p>Then, download the sshfs executable for Leopard, either the <a href="http://osxbook.com/download/sshfs/sshfs-static-leopard.gz">gzipped version</a> or the binary <a href="http://macfuse.googlecode.com/svn/trunk/filesystems/sshfs/binary/">from the SVN</a> as <a href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS">explained in the MacFuse wiki</a>.</p><p>From a terminal, rename the binary:</p><pre class="brush: bash; title: ; notranslate">
sudo mv ./sshfs-static-leopard ./sshfs
</pre><p>Then allow the binary to be executed and place it in the system:</p><pre class="brush: bash; title: ; notranslate">
sudo chmod +x sshfs
sudo install sshfs /usr/local/bin
</pre><p>From now you can test sshfs mounting with the following command:</p><pre class="brush: bash; title: ; notranslate">
sshfs user@myserver.net:/folder/ /Network/distant-folder -p 22
</pre><p>I personally had a problem here: sshfs complained about a missing library. I fixed this by downloading the required file from the <a href="http://www.macfusionapp.org">MacFusion project</a> and copying it beside the sshfs binary:</p><pre class="brush: bash; title: ; notranslate">
sudo wget http://www.macfusionapp.org/trac/export/86/trunk/SSHFS/sshnodelay.so
sudo mv ./sshnodelay.so /usr/local/bin/
sudo chmod +x /usr/local/bin/sshnodelay.so
</pre><p>If this fail you can also check:</p><ul><li>that the current user you&#8217;re logged with has access to the distant server with the <code>ssh user@myserver.net</code> command;</li><li>or that the local mount point exists (you can create it with <code>mkdir -p /Network/distant-folder</code>);</li><li>and finally, you can add the <code>-o debug</code> option to the sshfs command above to get additional clues.</li></ul><p>Now we will automate the mounting of sshfs at every start.</p><p>At this point I recommend you to register the <code>root</code> user of your MacOSX system to the distant server:</p><pre class="brush: bash; title: ; notranslate">
sudo cat ~/.ssh/id_rsa.pub | sudo ssh -p 22 user@myserver.net &quot;cat &gt;&gt; ~/.ssh/authorized_keys&quot;
</pre><p>If doesn&#8217;t exists, we have to create the <code>/etc/fstab</code> to edit it:</p><pre class="brush: bash; title: ; notranslate">
sudo touch /etc/fstab
sudo vi /etc/fstab
</pre><p>And add the following directives:</p><pre class="brush: plain; title: ; notranslate">
dummy:user@myserver.net:/folder/ /Network/distant-folder sshfs allow_other,auto_cache,reconnect,port=22,follow_symlinks,volname=&quot;Distant folder&quot; 0 0
</pre><p>As you can see I&#8217;ve added lots of options to accommodate my uses. You can get more informations about sshfs options through traditional help pages:</p><pre class="brush: bash; title: ; notranslate">
sshfs --help
</pre><p>MacOSX&#8217;s automount daemon will look for a script called <code>mount_sshfs</code> at start. Actually it doesn&#8217;t exists on your system, but sshfs command line is compatible with what automount expect. So creating a symbolic link will do the trick:</p><pre class="brush: bash; title: ; notranslate">
sudo ln -s /usr/local/bin/sshfs /sbin/mount_sshfs
</pre><p>Finally, we can tell automount to acknowledge all our modifications:</p><pre class="brush: bash; title: ; notranslate">
sudo automount -vc
</pre>]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2009/09/fuse-sshfs-macosx-leopard/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Website Backup Script: bug fix release</title><link>http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/</link> <comments>http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/#comments</comments> <pubDate>Sun, 25 May 2008 23:38:44 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[FTP]]></category> <category><![CDATA[lftp]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[mysqldump]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[Script]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=222</guid> <description><![CDATA[14 months after the last release, here is a new version of my website backup script. As you can see in the changelog, this version is essentially released to fix some bugs. Changelog: Check version of Python (at least v2.4 &#8230; <a href="http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/">14 months after the last release</a>, here is a <a href="http://kevin.deldycke.com/static/scripts/website-backup-2008_05_25.py">new version of my website backup script</a>. As you can see in the changelog, this version is essentially released to fix some bugs.</p><p>Changelog:</p><ul><li>Check version of Python (at least v2.4 is required)</li><li>Rename <code>--debug</code> option to <code>--verbose</code></li><li>Add a <code>--dry-run</code> option for testing</li><li>Remove use of deprecated <code>pexpect</code> methods</li><li>Add and update some error messages</li></ul> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>System backup script: no more endless lock</title><link>http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/</link> <comments>http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/#comments</comments> <pubDate>Sun, 12 Aug 2007 15:00:45 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[Script]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[system]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/</guid> <description><![CDATA[I&#8217;ve just released a new version of my system-backup.py script. The main update is about the lock file, which I implemented in the last version to keep the script to run twice (or more) in parallel. This is a nice &#8230; <a href="http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve just released a <a href="http://kevin.deldycke.com/static/scripts/system-backup-2007_08_12.py">new version of my <code>system-backup.py</code> script</a>.</p><p>The main update is about the lock file, which I implemented in the <a href="http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/">last version</a> to keep the script to run twice (or more) in parallel. This is a nice feature to avoid overlapping processes that fight each other to use the same ressources. But in some extreme cases (reboot or power failure during backup, &#8230;), the lock file will remain and so will prevent the script to start (until you notice the problem and remove the lock file manually). This new version take care of this problem and is now able to remove the lock automatically if a timeout is reached. It also kill all remaining child processes.</p><p>Here is the detailed changelog:</p><ul><li>Auto-kill the script if the backup process take to much time. Timeout can be defined via a constant.</li><li>Clean kill: track all child processes to kill them safely before removing the lock file.</li><li>Require newer versions of python (>= v2.4), rsync (>= v2.6.7) and rdiff-backup (>= v1.1.0).</li><li>Use <code>--preserve-numerical-ids</code> option when adding rdiff-backup increment.</li><li>Keep 15 increments by default instead of 20. This value can be easily changed thanks to a defined constant.</li><li>Remove deleted file first during mirroring and delete outdated increments before adding a new one to gain space. This strategy is safer for target disk with low remaining free space.</li><li>Tell rsync to print human-readable values.</li></ul> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>System Backup on Unreliable Link thanks to rdiff-backup and rsync</title><link>http://kevin.deldycke.com/2007/04/system-backup-on-unreliable-link-thanks-to-rdiff-backup-and-rsync/</link> <comments>http://kevin.deldycke.com/2007/04/system-backup-on-unreliable-link-thanks-to-rdiff-backup-and-rsync/#comments</comments> <pubDate>Mon, 09 Apr 2007 06:01:35 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[Script]]></category> <category><![CDATA[SSH]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/04/system-backup-on-unreliable-link-thanks-to-rdiff-backup-and-rsync/</guid> <description><![CDATA[I&#8217;ve just write a brand new script called system-backup.py. It&#8217;s similar to my website-backup.py script but instead of website and MySQL databases, it is designed to backup systems of several machines. This script is based on an idea from the &#8230; <a href="http://kevin.deldycke.com/2007/04/system-backup-on-unreliable-link-thanks-to-rdiff-backup-and-rsync/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve just write a brand new script called <a href="http://kevin.deldycke.com/static/scripts/system-backup-2007_04_09.py"><code>system-backup.py</code></a>. It&#8217;s <a href="http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/">similar to my <code>website-backup.py</code> script</a> but instead of website and MySQL databases, it is designed to backup systems of several machines. This script is based on an idea from the &#8220;<a href="http://wiki.rdiff-backup.org/wiki/index.php/BackupUpOnUnreliableLink">Backup up on unreliable link</a>&#8221; article from the <a href="http://wiki.rdiff-backup.org">official rdiff-backup wiki</a>. It use <code>rdiff-backup</code> to keep the last 20 backups and <code>rsync</code> to speed-up the backup process.</p><p>I run this script to backup all the local machines within my LAN. I start the backup process everyday thanks to a <code>cron</code> entry similar to this one:</p><pre class="brush: bash; title: ; notranslate">
0 20 * * * root /root/system-backup.py &gt;&gt; /mnt/backup-disk/backup.log
</pre><p>If you need more information about the <code>rsync</code> part the script, please have a look to my previous <a href="http://kevin.deldycke.com/2005/04/remote-backup-with-rsync/">Remote Backup with rsync</a> article, which detail how-to setup key authentification with <code>ssh</code>.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/04/system-backup-on-unreliable-link-thanks-to-rdiff-backup-and-rsync/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Website Backup Script: MySQL dumps and SSH supported.</title><link>http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/</link> <comments>http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/#comments</comments> <pubDate>Sun, 25 Mar 2007 10:17:09 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[FTP]]></category> <category><![CDATA[lftp]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[mysqldump]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[Script]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/</guid> <description><![CDATA[Three months after the last version, here is a big update of my backup scripts for websites. The script was greatly improved and among new features, the most important is the support of backups over SSH and backups of MySQL &#8230; <a href="http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://kevin.deldycke.com/2006/12/website-backup-script-updated-take-care-of-hidden-files-now/">Three months after the last version</a>, here is a big update of <a href="http://kevin.deldycke.com/static/scripts/website-backup-2007_03_25.py">my backup scripts for websites</a>. The script was greatly improved and among new features, the most important is the support of backups over SSH and backups of MySQL databases.</p><p>Change log:</p><ul><li>Each item of the user&#8217;s <code>backup_list</code> must specify the <code>type</code> property (<code>FTP</code>, <code>FTPs</code>, <code>SSH</code>, <code>MySQLdump</code> or <code>MySQLdump+ssh</code>).</li><li>The property previously known as <code>site</code> is now <code>host</code>.</li><li>File system structure changed: <code>/ftp-mirror</code> folders renamed to <code>/mirror</code>.</li><li>Add SSH backups.</li><li>The script is able to detect if a SSH connexion can be initiated without a password. This was designed for people who don&#8217;t like the idea of storing clear password in the script. Thanks to this feature, you can benefit public key authentication from OpenSSH.</li><li>Use of <code>rsync</code> whenever it&#8217;s possible for bandwidth efficiency.</li><li>FTP and FTPs (aka FTP over SSL) are now handled separately: this suppress the default fall-back to FTP if FTPs is not supported by the remote server. This is safer as it doesn&#8217;t let <code>lftp</code> make the decision for you to send your clear password on the net.</li><li>All ports are optionnal, no need to specify it you use default ports.</li><li>Add MySQL backups thanks to <code>mysqldump</code>.</li><li>Two mode of MySQL backups: through SSH or direct connection to server.</li><li>A particular database to backup can be specified. Else, all databases are backed up.</li><li>Much more detailed logs that include external command&#8217;s output.</li><li>Auto-detect the existence of required external tools and commands at launch.</li><li>Use <code>pexpect</code> lib to simulate user password input.</li><li>Run all external commands in english for consistency.</li><li>Check that the script is running in a posix environnement.</li><li>Fix bug related to directory creation.</li></ul><p>If you were using a previous version of my backup script and want to use this updated version, take care of changes, especially the ones describes in the first 3 items of the change log above.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Remote Backup with rsync</title><link>http://kevin.deldycke.com/2005/04/remote-backup-with-rsync/</link> <comments>http://kevin.deldycke.com/2005/04/remote-backup-with-rsync/#comments</comments> <pubDate>Thu, 21 Apr 2005 12:20:43 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Mandriva]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[SSH]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2005/04/remote-backup-with-rsync/</guid> <description><![CDATA[This little article describe how to setup an automatic backup procedure to a remote machine via the rsync tool. Prerequisites A distant server, where backup will be stored (homeserver.com in this case), A user account on this server (mine was &#8230; <a href="http://kevin.deldycke.com/2005/04/remote-backup-with-rsync/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This little article describe how to setup an automatic backup procedure to a remote machine via the rsync tool.</p><h2>Prerequisites</h2><ul><li>A distant server, where backup will be stored (<code>homeserver.com</code> in this case),</li><li>A user account on this server (mine was <code>kevin</code>),</li><li>A ssh deamon running on the server that allow the user to log in.</li></ul><h2>Setup rsync</h2><p>First, install rsync on the client and on the server using:</p><pre class="brush: bash; title: ; notranslate">
urpmi rsync
</pre><h2>Synchronization</h2><p>Then, to synchronise from the local machine to the distant server, just do:</p><pre class="brush: bash; title: ; notranslate">
rsync -avz -e ssh /home/client_user/Documents kevin@homeserver.com:/mnt/raid2/
</pre><ul><li><code>/home/client_user/Documents</code> is the local folder we want to save (located in the home folder of the client user <code>client_user</code>),</li><li><code>homeserver.com</code> is the distant server name (could be en IP address),</li><li><code>kevin</code> is the distant user,</li><li><code>/mnt/raid2/</code> is the distant folder where we want to save the local one.</li></ul><h2>Croned synchronization</h2><p>First, create a pair of cryptographic keys (public, private):</p><pre class="brush: bash; title: ; notranslate">
ssh-keygen -t rsa
</pre><p>Then, from the local machine as user <code>client_user</code>, register you on the distant server:</p><pre class="brush: bash; title: ; notranslate">
ssh-copy-id -i ~/.ssh/id_rsa.pub kevin@homeserver.com
</pre><p>In case your distant machine&#8217;s SSH server is running on another port than 22 (which is the default port), let&#8217;s said 222, here is the command that emulate <code>ssh-copy-id</code> (as the later doesn&#8217;t have a port parameter):</p><pre class="brush: bash; title: ; notranslate">
cat ~/.ssh/id_rsa.pub | ssh -p 222 kevin@homeserver.com &quot;cat &gt;&gt; ~/.ssh/authorized_keys&quot;
</pre><p>Create a script named <code>rsync_data_backup.sh</code> that contain the command you&#8217;ve used previously to synchronize your data:</p><pre class="brush: bash; title: ; notranslate">
rsync -avz -e ssh /home/client_user/Documents kevin@homeserver.com:/mnt/raid2/
</pre><p>To run this script with a cron entry, the (unsecure) solution found is to create a key without a passphrase. The cron entry could be something like:</p><pre class="brush: bash; title: ; notranslate">
15 13 * * 1-5 client_user /home/client_user/rsync_data_backup.sh &gt; /home/client_user/rsync_data_backup.log
</pre><p>This crontab entry will automaticcaly synchronise our data each first-5 days of the week, at 13:15.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2005/04/remote-backup-with-rsync/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/44 queries in 0.020 seconds using apc
Object Caching 1069/1173 objects using apc

Served from: kevin.deldycke.com @ 2012-02-08 03:49:24 -->
