<?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>64k &#187; remote access</title>
	<atom:link href="http://www.64k-tec.de/tag/remote-access/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.64k-tec.de</link>
	<description>Software development and more ...</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:58:41 +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>TT: Uni-directional file synchronization between different hosts with Unison</title>
		<link>http://www.64k-tec.de/2011/11/tt-uni-directional-file-synchronization-between-different-hosts-with-unison/</link>
		<comments>http://www.64k-tec.de/2011/11/tt-uni-directional-file-synchronization-between-different-hosts-with-unison/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 21:19:25 +0000</pubDate>
		<dc:creator>cp</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Root]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Console]]></category>
		<category><![CDATA[directory management]]></category>
		<category><![CDATA[file synchronization]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[OpenSSH]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[Rsync]]></category>
		<category><![CDATA[secure communication]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[synchronization]]></category>
		<category><![CDATA[Synchronizer]]></category>
		<category><![CDATA[tooltips]]></category>
		<category><![CDATA[TT]]></category>
		<category><![CDATA[Unison]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://www.64k-tec.de/?p=2561</guid>
		<description><![CDATA[When you work with at least two computers on the same project on a daily basis you might have a problem. You need to get changed files from host A to host B and vice versa. The problem getting bigger when you work in addition on different operation systems or use more than two hosts. [...]]]></description>
			<content:encoded><![CDATA[<p>When you work with at least two computers on the same project on a daily basis you might have a problem. You need to get changed files from host A to host B and vice versa. The problem getting bigger when you work in addition on different operation systems or use more than two hosts. On UNIX/Linux the preferred tool for such a task is <a title="Rsync - fast incremental file transfer" href="http://rsync.samba.org/" target="_blank">Rsync</a>. Unfortunately Rsync synchronize only in one direction, it doesn't work very well when more than two hosts are involved (and it isn't really comfortable to set up on Windows) and can't use a secure communication channel. Another approach is to check-in changed source files into a <a title="Wikipedia: Revision Control Systems" href="http://en.wikipedia.org/wiki/Revision_control" target="_blank">version control system</a>, like <a title="Wikipedia: Concurrent Versions System" href="http://en.wikipedia.org/wiki/Concurrent_Versions_System" target="_blank">CVS</a>. On host A you check it in and on host B you check it out afterwards. But this means you always need a more or less stable variant of your code, so that other developer can, at least compile, or much better use it. That is not always the case (especially when you leave the office at 11:00 p.m.) and it also doesn't cover files which aren't handled by a version control system. Luckily there is a solution for all the problems mentioned which is called <a title="Unison - A File Synchronizer" href="http://www.cis.upenn.edu/~bcpierce/unison/" target="_blank">Unison</a>. So here comes the second post in the <a title="ToolTips - Useful applications for the daily business" href="/tag/tt/">ToolTips</a> series, which covers an easy and portable way for file synchronization.</p>
<h2>Installing Unison</h2>
<p>Most modern Linux distributions include Unison in their package manage system. On Mac OS X you can use <a title="The MacPorts Project Official Homepage" href="http://www.macports.org/" target="_blank">MacPorts</a>. Alternatively you could download a binary version for Mac OS X or Windows <a title="Binary versions of Unison" href="http://alan.petitepomme.net/unison/index.html" target="_blank">here</a>. To prevent surprises and unnecessary trouble it might be a good idea to make sure that every involved system use the same version of Unison. At least on Linux and Mac OS X it is relatively easy to compile Unison from the <a title="Unison sources" href="http://www.cis.upenn.edu/~bcpierce/unison/download.html" target="_blank">sources</a>.</p>
<h2>Setting up public/private key authentication for ssh</h2>
<p>One advantage of Unison over Rsync is that you can use different communication channels for the file transfers. One is ssh. As I always prefer/demand encrypted communication this is a big plus of course. In the default setup you can just use ssh. But for a little bit more comfort I suggest to create a public/private key pair for the authentication.<br />
<span class="sb_alert">The following creates public/private keys without a password. Although this is much more easier to use, it should be only used on hosts which are trusted. If you are in doubt, use the normal password approach or even better create a public/private key pair with a password.</span> Create a new public/private key pair with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host-a ~ $ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa</pre></div></div>

<p>When you are asked for a password just hit Enter twice. The command creates the private key in <code class="path">~/.ssh/id_rsa</code> and the public key in <code class="path">~/.ssh/id_rsa.pub</code>. Now copy the public key to host B:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host-a ~ $ <span style="color: #c20cb9; font-weight: bold;">scp</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub host_B:.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>If you already have some public keys on host B, make sure you append the new key and not overwrite the file by the above command. Make the file accessible by the user only with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host-b ~ $ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>Now you should be able to connect to host B without any interaction needed.</p>
<h2>Configuring Unison</h2>
<p>Like in the long UNIX tradition, Unison is configured using text files. The files are located in the <code class="path">~/.unison</code> directory. You can configure more than one synchronization target by choosing a meaningful name. There exists one default target which is configured in the file <code class="path">default.prf</code>. Because I have more than one target I prefer to split the configuration into several files. You can include other project files with the <code>include</code> statement as shown here:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># directory on host a (this is where Unison will be executed)</span>
root       = <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>projects
<span style="color: #666666; font-style: italic;"># directory on host b (this is the remote host)</span>
root       = <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>host-b<span style="color: #000000; font-weight: bold;">//</span>mnt<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>projects
<span style="color: #666666; font-style: italic;"># which directories to sync?</span>
include projects_files.prf
<span style="color: #666666; font-style: italic;"># options</span>
include options.prf
ignorecase = <span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #666666; font-style: italic;"># unison executable on the server</span>
servercmd  = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>unison</pre></div></div>

<p>We setup the root directories on both machines, including the configuration file for the project target and some generic option file. We also overwriting the default unison location, because this is a self compiled version. The file <code class="path">options.prf</code> looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># No staled nfs and mac store files</span>
ignore  = Name .nfs<span style="color: #000000; font-weight: bold;">*</span>
ignore  = Name .DS_Store
<span style="color: #666666; font-style: italic;"># options</span>
log     = <span style="color: #c20cb9; font-weight: bold;">true</span>
rsrc    = <span style="color: #c20cb9; font-weight: bold;">true</span>
auto    = <span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #666666; font-style: italic;">#debug   = verbose</span>
<span style="color: #666666; font-style: italic;">#logfile = ~/.unison/unison.log</span></pre></div></div>

<p>This just set some generic options which are valid for all my targets. For the specific target <strong>projects</strong> the file <code class="path">projects_files.prf</code> contains mainly the directories and files which should be ignored:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># No ISOs</span>
ignore    = Path vms<span style="color: #000000; font-weight: bold;">/</span>ISO
<span style="color: #666666; font-style: italic;"># Ignore VBox branches</span>
ignore    = Path vbox-<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #666666; font-style: italic;"># No binary output from the other platforms</span>
ignore    = Path vbox<span style="color: #000000; font-weight: bold;">*/</span>out<span style="color: #000000; font-weight: bold;">/*</span>
<span style="color: #666666; font-style: italic;"># One exception:</span>
ignorenot = Path vbox<span style="color: #000000; font-weight: bold;">/</span>out<span style="color: #000000; font-weight: bold;">/</span>linux.amd64.additions
<span style="color: #666666; font-style: italic;"># No wine stuff</span>
ignore    = Path vbox<span style="color: #000000; font-weight: bold;">*/</span>wine.<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #666666; font-style: italic;"># Tools</span>
ignore    = Name vbox<span style="color: #000000; font-weight: bold;">*/</span>tools<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>FetchDir,freebsd<span style="color: #000000; font-weight: bold;">*</span>,os2<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>So in general, you configure the directory to synchronize and later define directories or files which should be ignored. As you see, you can include or exclude paths as you like. Even simple bash wildcards are possible. As shown in this example I exclude all binary files of a VirtualBox build, because they are useless on another platform. Understanding how Unison decide which directories or files should be synchronized is sometimes difficult. So I suggest to carefully read the <a title="Unison - Documentation" href="http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html" target="_blank">documentation</a> and just use the "try and failure" approach <img src='http://www.64k-tec.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Another reason for splitting up the configuration files is you can synchronize these files as well. I have another target which synchronize several configuration files, e.g. <code class="path">.bashrc</code>, <code class="path">.profile</code>, <code class="path">.vim*</code> and the sub-project files of Unison like the <code class="path">projects_files.prf</code>. You can't synchronize e.g. <code class="path">default.prf</code>, cause the root directories are different from host to host, but the general configuration is always the same. My <strong>home</strong> target looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Which directories/files to sync?</span>
path = .bashrc
path = .ion3
path = .gdbinit
path = .cgdb
path = .valgrind-vbox.supp
path = .vim
path = .vimrc
path = .gvimrc
path = .Xdefaults
path = .gnupg
path = .unison<span style="color: #000000; font-weight: bold;">/</span>options.prf
path = .unison<span style="color: #000000; font-weight: bold;">/</span>home_files.prf
path = .unison<span style="color: #000000; font-weight: bold;">/</span>projects_files.prf
<span style="color: #666666; font-style: italic;"># Do not sync:</span>
ignore = Path .vim<span style="color: #000000; font-weight: bold;">/</span>.netrwhist
ignore = Path .ion3<span style="color: #000000; font-weight: bold;">/</span>default-session<span style="color: #000000; font-weight: bold;">*</span>
ignore = Path .cgdb<span style="color: #000000; font-weight: bold;">/</span>readline_history.txt</pre></div></div>

<p>One of the strengths over other synchronization tools is, you can do this for others host as well. So if you synchronize between host a and host b you can also synchronize between host c and host b. However, a little bit of discipline is necessary. There should be one host which all other host synchronize again.<br />
If you now execute <code class="cmd">unison</code> the project target will be used. If you execute <code class="cmd">unison home</code> the files of the home target will be synchronized.</p>
<h2>Conclusion</h2>
<p>Unison is a very powerful tool. You can synchronize between more than two hosts (OS independent), in a secure way and uni-directional. Currently there is no better tool and I use it on a daily basis.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.64k-tec.de/2011/11/tt-uni-directional-file-synchronization-between-different-hosts-with-unison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the backtrace from a kernel panic</title>
		<link>http://www.64k-tec.de/2010/10/getting-the-backtrace-from-a-kernel-panic/</link>
		<comments>http://www.64k-tec.de/2010/10/getting-the-backtrace-from-a-kernel-panic/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 17:56:31 +0000</pubDate>
		<dc:creator>cp</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[backtrace]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[graphical modes]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[kernel mode settings]]></category>
		<category><![CDATA[KMS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[netconsole]]></category>
		<category><![CDATA[panic]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://www.64k-tec.de/?p=1423</guid>
		<description><![CDATA[You may know the following situation. You arrive in the morning in the office, do what you always do and check out the latest changes of the software you are working on. After a little bit of compile time and the first coffee you start the just build application. Bumm, kernel panic. After rebooting and [...]]]></description>
			<content:encoded><![CDATA[<p>You may know the following situation. You arrive in the morning in the office, do what you always do and check out the latest changes of the software you are working on. After a little bit of compile time and the first coffee you start the just build application. Bumm, <a href="http://en.wikipedia.org/wiki/Kernel_panic" target="_blank"><strong>kernel panic</strong></a>. After rebooting and locking through the changes you may have an idea what the reason for this could be. A colleague of you is working on a fancy new feature which needed changes to a kernel module. As you almost know nothing about this code you seek for help and, as it of course not happen on his computer, he is asking for a <a href="http://en.wikipedia.org/wiki/Stack_trace" target="_blank">backtrace</a> of this panic. You have two problems now. First you need to see the panic yourself and second it would be nice to get a copy of the backtrace for sharing this info within a bugtracker. In the following post I will show how both aims could be easily archived.</p>
<h2>Let the kernel manage the graphical modes</h2>
<p>As most people are working under X11 they don't see the output of an kernel panic. When a kernel panic happens the kernel prints the reason for the panic and a kernel backtrace to the console window and stops immediately its own execution. It is not written into a log file or somewhere else. In consequence you don't have the ability to look into the panic text, cause the graphical mode is still on. Historically the mode settings are done by the graphic driver of the X11 system. So the kernel has no idea that or which graphic mode is currently in use. Fortunately the kernel hackers invented a new infrastructure which let the kernel do the mode switch. This subsystem is called <a href="https://fedoraproject.org/wiki/Features/KernelModesetting" target="_blank">Kernel-Mode-Settings (KMS)</a>. As the kernel do the mode settings, he can switch back to the console on a panic, regardless which graphical mode is currently configured. Beside this, KMS has other improvements like Fast User Switching or a flicker free switch between text and graphic mode. On the other side is this highly hardware dependent and even if it was introduced with version 2.6.28, not all today available hardware can make use of it. If you are an owner of an Intel graphic card you are in good shape. Radeon and NVidia cards have limited support through the in kernel drivers <a href="http://wiki.x.org/wiki/radeonhd" target="_blank">radeonhd</a> and <a href="http://nouveau.freedesktop.org/wiki/" target="_blank">nouveau</a>. For an Intel i915 card you need to enable the following kernel options:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">CONFIG_DRM_I915</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">y</span>
Location:
-&gt; Device Drivers
-&gt; Graphics support
-&gt; Direct Rendering Manager <span style="">&#40;</span>XFree86 4.1.0 and higher DRI support<span style="">&#41;</span> <span style="">&#40;</span>DRM <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="color: #000066; font-weight:bold;">=</span>y<span style="">&#93;</span></span><span style="">&#41;</span>
-&gt; Intel 830M, 845G, 852GM, 855GM, 865G <span style="">&#40;</span> <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="color: #000066; font-weight:bold;">=</span>y<span style="">&#93;</span></span><span style="">&#41;</span>
&nbsp;
<span style="color: #000099;">CONFIG_DRM_I915_KMS</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">y</span>
Location:
-&gt; Device Drivers
-&gt; Graphics support
-&gt; Direct Rendering Manager <span style="">&#40;</span>XFree86 4.1.0 and higher DRI support<span style="">&#41;</span> <span style="">&#40;</span>DRM <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="color: #000066; font-weight:bold;">=</span>y<span style="">&#93;</span></span><span style="">&#41;</span>
-&gt; Intel 830M, 845G, 852GM, 855GM, 865G <span style="">&#40;</span> <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="color: #000066; font-weight:bold;">=</span>y<span style="">&#93;</span></span><span style="">&#41;</span>
-&gt; i915 driver <span style="">&#40;</span>DRM_I915 <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="color: #000066; font-weight:bold;">=</span>y<span style="">&#93;</span></span><span style="">&#41;</span></pre></div></div>

<p>The kernel line in your favorite boot loader needs the following additional parameter:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">i915.modeset=1</pre></div></div>

<p>X11 should have this minimal configuration for the device section:</p>

<div class="wp_syntax"><div class="code"><pre class="xorg_conf" style="font-family:monospace;"><span style="color: #b1b100;">Section</span> <span style="color: #0000ff;">&quot;Device&quot;</span>
 <span style="color: #990000;">Identifier</span>    <span style="color: #0000ff;">&quot;i915&quot;</span>
 <span style="color: #990000;">Driver</span>        <span style="color: #0000ff;">&quot;intel&quot;</span>
 <span style="color: #990000;">Option</span>        <span style="color: #0000ff;">&quot;DRI&quot;</span>   <span style="color: #0000ff;">&quot;true&quot;</span>
<span style="color: #b1b100;">EndSection</span></pre></div></div>

<p>Please note that you need of course some recent kernel, X11 version and Intel X11 driver to make this work. After a compile, install and boot of the new kernel, KMS should be in use. You will notice it, cause the boot messages will be printed in a much higher graphical resolution, than the usual text mode provide. The next time a kernel panic occurs, the kernel will switch back to the console before the panic is printed. This allows you to see the info printed and maybe you get a useful hint for the reason of the panic.</p>
<h2>Post the panic</h2>
<p>If you can't use KMS or don't want transcribe the panic text by hand into the bugtracker, it would be nice if the text could be made available on another computer. Kernel hackers usual use the serial port for that. Unfortunately most modern computers doesn't have such a serial port anymore. Also you need two hosts with a serial port and the setup is complex (you have to know about <a href="http://en.wikipedia.org/wiki/Serial_port#Settings" target="_blank">baud-rates, parity</a> and stuff like this). But there is a simpler solution: <a href="http://www.mjmwired.net/kernel/Documentation/networking/netconsole.txt" target="_blank">netconsole</a>. Netconsole is a kernel module, which sends kernel messages anywhere to the net using UDP. The setup is really simple. In the kernel configuration you need the following setting:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">CONFIG_NETCONSOLE</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">m</span>
Location:
-&gt; Device Drivers
-&gt; Network device support <span style="">&#40;</span>NETDEVICES <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="color: #000066; font-weight:bold;">=</span>y<span style="">&#93;</span></span><span style="">&#41;</span></pre></div></div>

<p>I prefer to compile it as module, which allows me to turn it on only when I need it. Load it with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">modprobe netconsole <span style="color: #007800;">netconsole</span>=<span style="color: #000000; font-weight: bold;">@/</span>,<span style="color: #000000; font-weight: bold;">@</span>192.168.220.10<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>The ip has to be replaced by the one of your target computer. You can of course tune it much more, like setting source and target ports or even let netconsole send the text to more than one host. On your client you need a network tool which can read from a socket and print the read text to stdout. Netcat or nc are two tools which are able to do just that. The call for nc looks like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">nc <span style="color: #660033;">-l</span> <span style="color: #660033;">-u</span> <span style="color: #000000;">6666</span></pre></div></div>

<p>Now if a kernel panic will happen you will see an output like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [] rb_erase+0x15c/0x320
PGD 6942f067 PUD a1e4067 PMD 0
Oops: 0000 [#1] SMP
last sysfs file: /sys/devices/virtual/block/md1/dev
CPU 3
Modules linked in: vboxnetadp vboxnetflt vboxdrv netconsole ...
&nbsp;
Pid: 18887, comm: VirtualBox Tainted: G        W   2.6.36-gentoo #4 DG33TL/
RIP: 0010:[]  [] rb_erase+0x15c/0x320
RSP: 0018:ffff8800b430db58  EFLAGS: 00010046
RAX: 0000000000000000 RBX: ffff880069557a68 RCX: 0000000000000001
RDX: ffff880069557a68 RSI: ffff880001d8ed58 RDI: 0000000000000000
RBP: ffff8800b430db68 R08: 0000000000000001 R09: 000000008edcb5d6
R10: 0000000000000000 R11: 0000000000000202 R12: ffff880001d8ed58
R13: 0000000000000000 R14: 000000000000ed00 R15: 0000000000000002
FS:  00007fffde457710(0000) GS:ffff880001d80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 00000000064f9000 CR4: 00000000000026e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process VirtualBox (pid: 18887, threadinfo ffff8800b430c000, task ffff880091e227f0)
Stack:
 ffff88000a03ba18 ffff880001d8ed48 ffff8800b430dba8 ffffffff8105bf06
&lt;0&gt; ffff8800b430dba8 ffffffff8105c97c ffff8800b430dbc8 ffff88000a03ba18
&lt;0&gt; 00004ff8a86ba455 ffff880001d8ed48 ffff8800b430dc48 ffffffff8105ce77
Call Trace:
 [] __remove_hrtimer+0x36/0xb0
 [] ? lock_hrtimer_base+0x2c/0x60
 [] __hrtimer_start_range_ns+0x2b7/0x3c0
 [] ? rtR0SemEventMultiLnxWait+0x250/0x3d0 [vboxdrv]
 [] ? RTLogLoggerExV+0x12f/0x180 [vboxdrv]
 [] hrtimer_start+0x13/0x20
 [] rtTimerLnxStartSubTimer+0x60/0x120 [vboxdrv]
 [] rtTimerLnxStartOnSpecificCpu+0x21/0x30 [vboxdrv]
 [] rtmpLinuxWrapper+0x23/0x30 [vboxdrv]
 [] RTMpOnSpecific+0x99/0xa0 [vboxdrv]
 [] ? rtTimerLnxStartOnSpecificCpu+0x0/0x30 [vboxdrv]
 [] RTTimerStart+0x2a6/0x2e0 [vboxdrv]
 [] ? g_abExecMemory+0x33665/0x180000 [vboxdrv]
 [] g_abExecMemory+0xc678/0x180000 [vboxdrv]
 [] g_abExecMemory+0x328d7/0x180000 [vboxdrv]
 [] supdrvIOCtlFast+0x6a/0x70 [vboxdrv]
 [] VBoxDrvLinuxIOCtl+0x47/0x1e0 [vboxdrv]
 [] ? pick_next_task_fair+0xde/0x150
 [] do_vfs_ioctl+0xa1/0x590
 [] ? sys_futex+0x76/0x170
 [] sys_ioctl+0x4a/0x80
 [] system_call_fastpath+0x16/0x1b
Code: 07 a8 01 75 9d eb 81 0f 1f 84 00 00 00 00 00 48 3b 78 10 0f 84 ...
RIP  [] rb_erase+0x15c/0x320
 RSP
CR2: 0000000000000000
---[ end trace 4eaa2a86a8e2da24 ]---</pre></div></div>

<p>Normally only kernel panics are sent to the console. You can increase the verbosity level by executing <code>dmesg -n 8</code> as root.</p>
<h2>Conclusion</h2>
<p>To continue with the story from the beginning: With the shown methods you can hope your colleague get enough information to find the reason for the kernel panic. To be more helpful, the next step would be to try to debug the problem yourself. Even if the <a href="https://kgdb.wiki.kernel.org/index.php/Main_Page" target="_blank">KGDB</a> was merged into the kernel in version 2.6.35, it is not really usable for me. The reason is that it seems kernel hackers usually have really old hardware which either has a serial port, a PS/2 keyboard or both. Otherwise I can't find a reason why USB keyboards don't work. I <a href="http://sourceforge.net/mailarchive/forum.php?thread_name=4CC99477.8010801%40oracle.com&amp;forum_name=kgdb-bugreport" target="_blank">asked</a> on the mailing list of KGDB about the status of USB keyboard support and I can only hope support will be integrated soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.64k-tec.de/2010/10/getting-the-backtrace-from-a-kernel-panic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FRITZ!Box tuning part 3: Using the VoIP phone line from everywhere</title>
		<link>http://www.64k-tec.de/2010/02/fritzbox-tuning-part-3-using-the-voip-phone-from-everywhere/</link>
		<comments>http://www.64k-tec.de/2010/02/fritzbox-tuning-part-3-using-the-voip-phone-from-everywhere/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 12:24:27 +0000</pubDate>
		<dc:creator>cp</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Root]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[FritzBox]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[phone calls]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[softphone]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://www.64k-tec.de/?p=667</guid>
		<description><![CDATA[The contract with my Internet service provider includes a VoIP connection. Together with the FRITZ!Box 7270 all phone calls are done over the Internet, an additional conventional phone connection isn't necessary anymore. One of the benefits of this is that you can connect to your registrar from everywhere in the world. But that's theory, cause [...]]]></description>
			<content:encoded><![CDATA[<p>The contract with my Internet service provider includes a VoIP connection. Together with the FRITZ!Box 7270 all phone calls are done over the Internet, an additional conventional phone connection isn't necessary anymore. One of the benefits of this is that you can connect to your registrar from everywhere in the world. But that's theory, cause e.g. my provider doesn't allow a connection if you are not in the network of the provider itself. Of course there are free services like <a href="http://www.sipgate.de" target="_blank">sipgate</a> or even Skype. There you could make free calls within the services itself, but as soon as you like to call a real phone number you have to pay. They are cheap, no question, but my contract includes a flat rate within Germany. That's even cheaper. So what I like to do is to use my VoIP phone connection even when I'm not at home. In the following third part of the FRITZ!Box tuning <a href="/tag/fritzbox/">series</a>, I will explain how to achieve this. As already said in the first two post, where you at least should read the <a href="http://www.64k-tec.de/2010/01/fritzbox-tuning-part-1-enable-remote-access-over-ssh/">first</a> one, I'm not responsible for anything happens to your FRITZ!Box after you have tried what is described here.</p>
<h2>Adding a softphone to the FRITZ!Box</h2>
<p>The FRITZ!Box fully supports softphones in its basic configuration. Adding new softphones is done in the web frontend in the extended configuration section. There is a wizard for this, where you have to answer some question about your new device. Select phone as device, LAN/WLAN (IP-Phone) for the connection type, choose a name and a password. You get a new internal phone number which usually starts at 620 for the first created device. The FRITZ!Box try's than to connect to the new device. You can skip this for now. After that you have to select which official phone number the new device should use. This is important cause this will be displayed as the caller id when you make a call. Now you could choose if the new softphone should react on all incoming calls, regardless of the phone number called, or only on a specific one.</p>
<h2>Configuring the client software</h2>
<p>I will explain the client setup with the help of a free VoIP software called <a href="http://code.google.com/p/telephone/" target="_blank">Telephone</a>. It's only available for Mac OS X, but there are many other VoIP clients out there which also works for other operation systems. After downloading and installing it you have to create a new account. Select a descriptive name for the account. For the domain use <em>fritz.box</em>, as username you have to use the internal number the FRITZ!Box selected above. Lets use 620 for now. The password is the one you chose previously. After the account is created, I had to select <em>Substitute "00" for "+"</em> in the advanced settings, cause the phone numbers in my address book are all saved with the international phone prefix of Germany which is +49. Assuming you are working in your home network right now, you should be able to connect with Telephone to your FRITZ!Box. Some simple tests like making an outgoing and incoming call with an additional mobile phone should verify a working setup. Some nice features like the Mac OS X Address Book integration, which also transfers incoming caller id's to real names if they are found in the address book, making Telephone a really useful application. For further phone call management functionality on Mac OS X, I can advice you to take a look at the also free software <a href="http://nexem.info/nexem-dev/" target="_blank">Frizzix</a>.</p>
<h2>Allowing calls from everywhere</h2>
<p>All the previously isn't any magic, cause it uses build in support of the FRITZ!Box. But this article is about allowing connections to the VoIP part of the FRITZ!Box from everywhere. To make this happen we have to edit an internal configuration file of the FRITZ!Box. This time we aren't change the ar7.cfg file, but a file called <code class="path">/var/flash/voip.cfg</code>. As the name suggest there is most of the VoIP configuration included. Use nvi to edit it and search for a section called <em>extensions</em>. There should be a newly created one which have a value <em>extension_number</em> with 620. Change the value <em>reg_from_outside</em> from <em>no</em> to <em>yes</em>. This section should then look like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">extensions <span style="">&#123;</span>
    <span style="color: #000099;">enabled</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><span style="color: #666666; font-style: italic;">;</span>
    <span style="color: #000099;">username</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;$$$$SSFSDFSOPKSFDOPK;LWE§REWSDFMKFSLDF3232SDFSDFSDF&quot;</span><span style="color: #666666; font-style: italic;">;</span>
    <span style="color: #000099;">authname</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;&quot;</span><span style="color: #666666; font-style: italic;">;</span>
    <span style="color: #000099;">passwd</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;$$$$DFS342ASDFSDFDSFDS§344WLKKHMSJHAJHASDAHQASLKADJSA&quot;</span><span style="color: #666666; font-style: italic;">;</span>
    <span style="color: #000099;">extension_number</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 620</span><span style="color: #666666; font-style: italic;">;</span>
    <span style="color: #000099;">reg_from_outside</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><span style="color: #666666; font-style: italic;">;</span>
    <span style="color: #000099;">tx_packetsize_in_ms</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 0</span><span style="color: #666666; font-style: italic;">;</span>
<span style="">&#125;</span></pre></div></div>

<p>Save the file and reboot your FRITZ!Box by typing <code>reboot</code>. Next we have to tell Telephone to use a proxy when connecting to the FRITZ!Box. Go to the advanced settings and add your DynDNS name, in this example it would be <em>xtestx.dyndns.org</em>, to the proxy field. That's all. Now you should be able to make calls from every network you are currently logged in.</p>
<h2>Conclusion</h2>
<p>This simple change to the internal configuration of the FRITZ!Box allows you to use your VoIP account from everywhere over the world. As nice this feature is, I like to add some words of caution at the end. First you need a good download and especially a good upload connection speed in your home setup, cause all phone calls are routed over the FRITZ!Box. Secondly I didn't know if VoIP transfers are encrypted in any way, so be aware that there is the possibility someone monitor your calls. And as last note you should understand that you opened a port on your FRITZ!Box for everyone, which in the case your password is stolen, could be abused. In the worst case someone use your account to SPAM other people or call expensive service numbers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.64k-tec.de/2010/02/fritzbox-tuning-part-3-using-the-voip-phone-from-everywhere/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>FRITZ!Box tuning part 2: Access your home network with OpenVPN</title>
		<link>http://www.64k-tec.de/2010/02/fritzbox-tuning-part-2-access-your-home-network-with-openvpn/</link>
		<comments>http://www.64k-tec.de/2010/02/fritzbox-tuning-part-2-access-your-home-network-with-openvpn/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 18:38:47 +0000</pubDate>
		<dc:creator>cp</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Root]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[FritzBox]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[PKI]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://www.64k-tec.de/?p=379</guid>
		<description><![CDATA[AVM has built a VPN server into the FRITZ!Box, why should I use some other software for this job, you may ask. The reason is quite simple: the build in one is a piece of closed source software written by AVM and there is only one official client which could be used to connect to [...]]]></description>
			<content:encoded><![CDATA[<p>AVM has built a VPN server into the FRITZ!Box, why should I use some other software for this job, you may ask. The reason is quite simple: the build in one is a piece of closed source software written by AVM and there is only one official client which could be used to connect to it, the FRITZ!VPN software. This client software is only available for the Windows operation system family and so by no means anything useful to me. I'm pretty sure they are using some official protocol like <a href="http://en.wikipedia.org/wiki/IPsec" target="_blank">IPSec</a>, so it might be possible to connect to the FRITZ!Box with other clients as well, but that's something I didn't want to try. <a href="http://openvpn.net" target="_blank">OpenVPN</a> on the other side is a rock solid open source software which could be used from many popular OS's these days. Even graphical clients, like <a href="http://code.google.com/p/tunnelblick/" target="_blank">TunnelBlick</a> for Mac OS X, are available. So here comes the second article of the FRITZ!Box tuning <a href="/?s=FRITZ!Box+tuning">series</a>, which will explain how to convert your FRITZ!Box into a OpenVPN server, where any number of clients can concurrently be connected. I highly recommend to read the <a href="http://www.64k-tec.de/2010/01/fritzbox-tuning-part-1-enable-remote-access-over-ssh/">first part</a> of this series, because this post is build on top of the stuff done there. This count especially for the filesystem layout on the usbstick and the way additional software is started. Also in the following it will be helpful to have ssh access to the FRITZ!Box all the time. As already written in the first part, there is no guarantee that the information presented here will work on your side or that I'm responsible for anything happen to your FRITZ!Box. In preparation of the following you need access to a second OpenVPN installation which will be used to create all necessary certificates and keys and which could be used to test the installation afterward. I'm using a Gentoo Linux host where you could install OpenVPN simply by executing <code>emerge openvpn</code>. Make sure you have the <strong>examples</strong> USE flag set to get all the helper scripts which make the life much more easier.</p>
<h2>The agony of choice</h2>
<p>OpenVPN could be configured in many different ways. So first of all we have to decide which features of OpenVPN we will use. In its simplest variant OpenVPN could be used with one preshared static key. The advantage of this setup type is the easy configuration. The disadvantage is that only one client could be connected at the time. That is not what we want, so we will configure our setup to be using a <a href="http://en.wikipedia.org/wiki/Public_key_infrastructure" target="_blank">Public Key Infrastructure</a> (PKI). This allows more than one client to be connected at the time and it is possible to mark single keys invalid without affecting other client keys. The second question which has to be answered is, if we want use routing or bridging in our setup. Again, routing is simpler to set up and also a little bit faster than bridging. Bridging on the other side allows the tunneling of non IP protocols such as IPX, tunnel all the IP broadcast and make it possible to use the same subnet on the client side as on the server-side. Especially the last point is a nice feature as with routing all hosts on the server-side needs a routing table entry to find the connected clients. But my main reason for preferring bridging over routing is the broadcast feature of the first one. In my home network works a NAS station as a file server. This includes of course simple filesystem sharing with AFP and NFS, but also serves this box audio data with the <a href="http://en.wikipedia.org/wiki/Digital_Audio_Access_Protocol" target="_blank">Digital Audio Access Protocol</a> (DAAP). DAAP is used by Apple in iTunes to share music with other clients in the network and that is what my NAS station does. This protocol, as well AFP, using broadcast messages (ZeroConf) to find some potential clients. So now it should be clear why I want bridging, it allows me to hear music or to simply connect to my file station without any interaction.</p>
<h2>Building up a PKI</h2>
<p>To create all necessary certificates and keys we are using the <em>easy-rsa</em> scripts from OpenVPN. They are located under <code class="path">/usr/share/openvpn/easy-rsa</code>. First we change the <code class="path">vars</code> file. On the bottom of the file are personal information defined which should be changed to fit to your environment. The entries looking as follow on my side (with a pseudo email address).</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">export KEY_COUNTRY<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;DE&quot;</span>
export KEY_PROVINCE<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;Sachsen&quot;</span>
export KEY_CITY<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;Dresden&quot;</span>
export KEY_ORG<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;64k&quot;</span>
export KEY_EMAIL<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;you@yourdomain.org&quot;</span></pre></div></div>

<p>You could also increase the <strong>KEY_SIZE</strong> from 1024 to 2048 within that file. This should make your keys unbreakable for the next few <span style="text-decoration: line-through;">decades</span> years. Now we are ready to create the master-key and the master certificate of the Certificate Authority (CA) by executing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> vars
.<span style="color: #000000; font-weight: bold;">/</span>clean-all
.<span style="color: #000000; font-weight: bold;">/</span>build-ca</pre></div></div>

<p>Please be aware that this will delete all previously created keys. Answering all questions with the default values should be sufficient. Next the key for the server has to be created.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>build-key-server server</pre></div></div>

<p>You can again accept all default values. A challenge password is not necessary, but you have to sign the certificate. Now its time for our first client key and certificate. You could the following repeat again and again, for every new client you want allow to access the OpenVPN server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>build-key client</pre></div></div>

<p>Again, don't forget to sign the key. If you ever have to mark a client certificate invalid you could do it with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>revoke-full client</pre></div></div>

<p>This will create or update a Certificate Revocation List (CRL)<em> </em> file which will be later used by the server to verify the certificate integrity of a connecting client. For now we create an empty one with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">KEY_CN</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #007800;">KEY_OU</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #007800;">KEY_NAME</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #007800;">$OPENSSL</span> ca <span style="color: #660033;">-gencrl</span> <span style="color: #660033;">-out</span> keys<span style="color: #000000; font-weight: bold;">/</span>crl.pem <span style="color: #660033;">-config</span> <span style="color: #007800;">$KEY_CONFIG</span></pre></div></div>

<p>The last step in this key building marathon is to create a <a href="http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange" target="_blank">Diffie-Hellman</a> key. This key will be used to initiate the secure channel between the two parties. Its created by:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>build-dh</pre></div></div>

<h2>Creating the server and client configuration</h2>
<p>We start with the configuration of the server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># set the path to the tap device</span>
dev tap
dev-node <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>tap0
mssfix
tun-mtu <span style="color: #000000;">1500</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># TCP or UDP server?</span>
proto udp
port <span style="color: #000000;">1194</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># CA and key files</span>
ca <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>ca.crt
cert <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>server.crt
key <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>server.key
crl-verify <span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>crl.pem <span style="color: #666666; font-style: italic;"># this is opened after the chroot</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Diffie hellman parameters</span>
<span style="color: #c20cb9; font-weight: bold;">dh</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>dh1024.pem
&nbsp;
<span style="color: #666666; font-style: italic;"># bridge setup</span>
server-bridge 192.168.220.1 255.255.255.0 192.168.220.50 192.168.220.99
mode server
tls-server
push <span style="color: #ff0000;">&quot;dhcp-option DNS 192.168.220.1&quot;</span>
&nbsp;
ifconfig-pool-persist ipp.txt
client-to-client
&nbsp;
<span style="color: #666666; font-style: italic;"># compression?</span>
comp-lzo
&nbsp;
<span style="color: #666666; font-style: italic;"># The maximum number of concurrently connected clients we want to</span>
<span style="color: #666666; font-style: italic;"># allow.</span>
max-clients <span style="color: #000000;">20</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># It's a good idea to reduce the OpenVPN daemon's privileges after</span>
<span style="color: #666666; font-style: italic;"># initialization.</span>
user nobody
group nobody
&nbsp;
<span style="color: #666666; font-style: italic;"># Put openvpn in a jail.</span>
<span style="color: #c20cb9; font-weight: bold;">chroot</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>openvpn
&nbsp;
<span style="color: #666666; font-style: italic;"># The persist options will try to avoid accessing certain resources on</span>
<span style="color: #666666; font-style: italic;"># restart that may no longer be accessible because of the privilege</span>
<span style="color: #666666; font-style: italic;"># downgrade.</span>
persist-key
persist-tun
&nbsp;
<span style="color: #666666; font-style: italic;"># where to log</span>
log-append <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>openvpn.log
&nbsp;
<span style="color: #666666; font-style: italic;"># verbose level for debugging</span>
;verb <span style="color: #000000;">4</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># make sure the connection is kept alive</span>
keepalive <span style="color: #000000;">10</span> <span style="color: #000000;">120</span></pre></div></div>

<p>For bridged mode it is essential that OpenVPN uses a TAP device and not the TUN device mode (see <a href="http://en.wikipedia.org/wiki/TUN/TAP" target="_blank">here</a> for the reason). We use UDP as the transport protocol and enable compression. Also we want that OpenVPN drops its privileges after the initialization and chroot into a jail to make it a little bit more secure. As the subnet for clients 192.168.220.0/24 is used. That is the same as my internal network uses. OpenVPN is allowed to use addresses ranging from 192.168.220.50 to 192.168.220.99. You have to make sure that the FRITZ!Box (or any other DHCP server in your network) doesn't serve addresses from that range. Of course you could change some of the settings to your needs, but then you have to make sure they match the configuration of the client.</p>
<p>Next we create the client configuration, which looks as follow:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Specify that we are a client and that we will be pulling certain</span>
<span style="color: #666666; font-style: italic;"># config file directives from the server.</span>
client
&nbsp;
<span style="color: #666666; font-style: italic;"># The hostname/IP and port of the server.</span>
remote xtestx.dyndns.org <span style="color: #000000;">1194</span>
&nbsp;
proto udp
dev tap
&nbsp;
pull
&nbsp;
mssfix
tun-mtu <span style="color: #000000;">1500</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># SSL/TLS parms.</span>
tls-client
ca keys<span style="color: #000000; font-weight: bold;">/</span>ca.crt
cert keys<span style="color: #000000; font-weight: bold;">/</span>client.crt
key keys<span style="color: #000000; font-weight: bold;">/</span>client.key
&nbsp;
ns-cert-type server
&nbsp;
<span style="color: #666666; font-style: italic;"># Keep trying indefinitely to resolve the host name of the OpenVPN</span>
<span style="color: #666666; font-style: italic;"># server. Very useful on machines which are not permanently connected</span>
<span style="color: #666666; font-style: italic;"># to the Internet such as laptops.</span>
resolv-retry infinite
&nbsp;
<span style="color: #666666; font-style: italic;"># Don't enable this; It must be disabled for iTunes to find the iTunes</span>
<span style="color: #666666; font-style: italic;"># server and for AFP broadcast in general.</span>
<span style="color: #666666; font-style: italic;">#nobind</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Downgrade privileges after initialization (non-Windows only)</span>
user nobody
group nobody
&nbsp;
<span style="color: #666666; font-style: italic;"># Try to preserve some state across restarts.</span>
persist-key
persist-tun
&nbsp;
<span style="color: #666666; font-style: italic;"># Enable compression on the VPN link.</span>
comp-lzo
&nbsp;
<span style="color: #666666; font-style: italic;"># debug level</span>
;verb <span style="color: #000000;">4</span>
&nbsp;
mute-replay-warnings
mute <span style="color: #000000;">20</span></pre></div></div>

<p>You have to change the <em>remote</em> hostname to your needs. You may also add the full path to the certificates and keys depending on your client OpenVPN installation.</p>
<p>Next we pack all files up for the server and the client respectively. The server needs the following one:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server.conf
keys<span style="color: #000000; font-weight: bold;">/</span>ca.crt
keys<span style="color: #000000; font-weight: bold;">/</span>crl.pem
keys<span style="color: #000000; font-weight: bold;">/</span>dh1024.pem
keys<span style="color: #000000; font-weight: bold;">/</span>server.crt
keys<span style="color: #000000; font-weight: bold;">/</span>server.key</pre></div></div>

<p>The client needs this one:<a name="client_pack"></a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">client.conf
keys<span style="color: #000000; font-weight: bold;">/</span>ca.crt
keys<span style="color: #000000; font-weight: bold;">/</span>client.crt
keys<span style="color: #000000; font-weight: bold;">/</span>client.key
keys<span style="color: #000000; font-weight: bold;">/</span>server.crt</pre></div></div>

<h2>Customizing the FRITZ!Box</h2>
<p>Connect to your FRITZ!Box and copy all the server files to the usbstick. I created a directory <code class="path">openvpn</code> under the <code class="path">/var/media/ftp/FLASH-DISK-01/addons</code> path. Next we need the OpenVPN binary for the FRITZ!Box. You can get it <a href="http://www.cswpro.de/_files/openvpn_kernel_2_6.zip">here</a>. Unpack the file and copy the openvpn binary to <code class="path">/var/media/ftp/FLASH-DISK-01/addons/bin</code> on the FRITZ!Box. Make sure the file mode has the executable bit set for the user. All files are now on the right places, so we can adjust our start script. Add the following code to the <code class="cmd">startup.sh</code> file.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Add a nobody user</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'nobody:x:65534:65534:nobody:/:/bin/false'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Add some groups</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'root:x:0:'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>group
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'nobody:x:65534:'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>group
&nbsp;
<span style="color: #666666; font-style: italic;"># Create a tap device for openvpn</span>
<span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>tap0 c <span style="color: #000000;">10</span> <span style="color: #000000;">200</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Start openvpn</span>
<span style="color: #800000;">${BASE}</span><span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>openvpn <span style="color: #660033;">--config</span> <span style="color: #800000;">${BASE}</span><span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>server.conf <span style="color: #660033;">--daemon</span></pre></div></div>

<p>As you see, we add a new <em>nobody</em> user to the Linux system. Then the device node for the TAP device is created and at the end the OpenVPN server is started. As we using the bridged setup, we have to add the new device to a bridge. Fortunately we haven't to create one, cause the FRITZ!Box itself is working in bridged mode. You can confirm this by executing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brctl show lan</pre></div></div>

<p>To let the system automatically add our TAP device to the <em>lan</em> bridge, we change the internal FRITZ!Box configuration. Edit the <code class="path">/var/flush/ar7.cfg</code> file with nvi and search for the string <em>brinterfaces</em>. There should be one section with the name <em>lan</em>. Simply add the new <em>tap0</em> interface to the interfaces value. The section should then look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">brinterfaces <span style="">&#123;</span>
     <span style="color: #000099;">name</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;lan&quot;</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">dhcp</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> no</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">ipaddr</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 192.168.220.1</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">netmask</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 255.255.255.0</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">dstipaddr</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 0.0.0.0</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">interfaces</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;eth0&quot;</span>, <span style="color: #933;">&quot;ath0&quot;</span>, <span style="color: #933;">&quot;tap0&quot;</span>, <span style="color: #933;">&quot;wdsup1&quot;</span>, <span style="color: #933;">&quot;wdsdw1&quot;</span>,
                  <span style="color: #933;">&quot;wdsdw2&quot;</span>, <span style="color: #933;">&quot;wdsdw3&quot;</span>, <span style="color: #933;">&quot;wdsdw4&quot;</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">dhcpenabled</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">dhcpstart</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 192.168.220.100</span><span style="color: #666666; font-style: italic;">;</span>
     <span style="color: #000099;">dhcpend</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 192.168.220.200</span><span style="color: #666666; font-style: italic;">;</span>
<span style="">&#125;</span></pre></div></div>

<p>Now, as soon the tap0 interface is created it will be added to the bridge. The last important point in the server setup is to change the internal firewall to allow connections to port 1194 from the outside. Search for <em>forwardrules</em> in the <code class="path">ar7.cfg</code> file and add this new rule:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">forwardrules</span> <span style="color: #000066; font-weight:bold;">=</span>
               <span style="color: #933;">&quot;tcp 0.0.0.0:7777 0.0.0.0:22 0 # SSH-Server&quot;</span>,
               <span style="color: #933;">&quot;udp 0.0.0.0:1194 0.0.0.0:1194 0 # VPN-Server&quot;</span><span style="color: #666666; font-style: italic;">;</span></pre></div></div>

<p>Thats all for the server. A reboot of the FRITZ!Box should start the new OpenVPN server. If you have trouble you should manually start the OpenVPN server and increase the debugging level, as shown in the above configuration with the keyword <em>verb</em>.</p>
<h2>Setting up the client</h2>
<p>On the client side we need the files we packed <a href="#client_pack">above</a>. On Gentoo the OpenVPN configuration is located at <code class="path">/etc/openvpn</code>. Copy the configuration, the certificates and the key file to that place. The OpenVPN start script of Gentoo looks for the configuration file, based on the start script name. So we have to create a link like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> client.conf openvpn.conf</pre></div></div>

<p>By the way, this lets you configure more than one OpenVPN connection at the time. Just create a link in <code class="path">/etc/init.d</code> with the new configuration name and link it to the <code class="path">openvpn</code> start script.</p>
<p>To make a first attempt to start the OpenVPN connection type</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>openvpn start</pre></div></div>

<p>If  all goes well you should have a new device <em>tap0</em> when you  execute <code>ifconfig</code>. Also there should be a route set,  which point to the tap0  device when the 192.168.220.0/24 subnet is the  target. Of course now you should be able to connect to any host in your  home network by the IP. I didn't experiment enough with the pushing of  the name server from the OpenVPN server, instead I just added the  FRITZ!Box as an additionally name server to my <code class="path">/etc/resolv.conf</code>. So here is room for further experiments.</p>
<p>To let the OpenVPN client start at boot time add it to the default runlevel by executing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rc-update add openvpn default</pre></div></div>

<p>Also note that with the above configuration the client always try to  reconnect to the server, even if the FRITZ!Box is rebooted, which is a nice feature.</p>
<h2>Conclusion</h2>
<p>This setup allows you to connect to your home network in a very secure way without loosing any functionality. You are able to browse network shares on the local network or using services like DAAP without any further interaction.  The public key infrastructure make this setup a candidate for small business installations. If an employee leave the company his certificate is simply revoked without affecting the access of other employees.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1754px; width: 1px; height: 1px; overflow: hidden;"><a href="http://www.cswpro.de/Howto/FritzBox_OpenVPN.aspx" target="_blank">http://wwww.cswpro.de</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.64k-tec.de/2010/02/fritzbox-tuning-part-2-access-your-home-network-with-openvpn/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>FRITZ!Box tuning part 1: Enable remote access over ssh</title>
		<link>http://www.64k-tec.de/2010/01/fritzbox-tuning-part-1-enable-remote-access-over-ssh/</link>
		<comments>http://www.64k-tec.de/2010/01/fritzbox-tuning-part-1-enable-remote-access-over-ssh/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 10:44:17 +0000</pubDate>
		<dc:creator>cp</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Root]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[FritzBox]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://www.64k-tec.de/?p=257</guid>
		<description><![CDATA[Recently I changed my Internet service provider to Kabel Deutschland which offers some really good bandwidth for a reasonable price. You get 32 MBit in the download direction and 2 Mbit in the upload direction. Additionally to this you can order a FRITZ!Box 7270 which allows you to use VoIP for the phone part. As [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I changed my Internet service provider to Kabel Deutschland which offers some really good bandwidth for a reasonable price. You get 32 MBit in the download direction and 2 Mbit in the upload direction. Additionally to this you can order a FRITZ!Box 7270 which allows you to use VoIP for the phone part. As I always try to maximize the usage of new hardware I started to explore what is possible with this combination. In this post I will explain how you get access to your FRITZ!Box using ssh. Following this post, some articles about how you can turn the FRITZ!Box into a OpenVPN server and how you can use the VoIP access point remotely from any computer having a VoIP software installed, will be done. As I said the hardware used is a FRITZ!Box Fon WLAN 7270 with the firmware 54/74.04.80 from 2009/12/15 which is an official one from AVM. Other firmware versions may work also, but I haven't tested that. The following topics are all for advanced user. So if you aren't in touch with Linux or start asking what the hell is vi and how get I out of it, stop reading now. All the information in this and the following posts are based on several websites I found in the Internet. Mainly this are some forum entries at <a href="http://www.ip-phone-forum.de" target="_blank">http://www.ip-phone-forum.de</a>, the series about the FRITZ!Box at <a href="http://www.tecchannel.de/server/extra/432803/tuning_hacks_fritzbox_fritz_box_erweiterungen_ftp_telnet/" target="_blank">http://www.tecchannel.de</a>, the posts on <a href="http://www.teamarbyte.de/ssh-fritzbox.html" target="_blank">http://www.teamarbyte.de</a>, the blog at <a href="http://www.realriot.de/category/hardware/fritzbox/" target="_blank">http://www.realriot.de</a> and this article at <a href="http://www.cswpro.de/Howto/FritzBox_OpenVPN.aspx" target="_blank">http://www.cswpro.de</a>. So thanks to all the people for sharing this kind of information. Before we start some words of caution: It's easily possible to render the FRITZ!Box unusable. So there is no warranty of any kind if you do some of the things mentioned in this blog. Also I'm not responsible for anything happen to your FRITZ!Box or the Internet connection. After all making a backup of your current configuration might be a good idea.</p>
<h2>Preparing the FRITZ!Box</h2>
<p>First of all you should register an account at <a href="http://www.dyndns.com" target="_blank">http://www.dyndns.com</a> or any other service for dynamic IP resolution. You can then add this information to the "DynamicDNS" tab of the Internet settings in the FRITZ!Box web frontend. This will allow you to connect to your FRITZ!Box without knowing the IP after a reconnect. Lets use us <em>xtestx.dyndns.org</em> in the following examples. Next you need telnet access to the FRITZ!Box to make the initial configuration for the ssh server. Enabling telnet is as simple as calling <strong><tt>#96*7*</tt></strong> with a local connected phone. To disable the telnet daemon later you call <strong><tt>#96*8*</tt></strong>. Now you need a usbstick where all the software will be installed on and which have to be connected to the FRITZ!Box all the time. In principle the size doesn't matter, around 5 MBytes free space should be enough. Time to connect to the FRITZ!Box for the first time. A simple <code class="cmd">telnet fritz.box</code> should do it.</p>
<h2>Installation and configuration of the ssh server</h2>
<p>For the ssh server software <a href="http://matt.ucc.asn.au/dropbear/dropbear.html" target="_blank">dropbear</a> is used. You can get a prepared version for the FRITZ!Box from the spblinux server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.spblinux.de<span style="color: #000000; font-weight: bold;">/</span>fbox.new<span style="color: #000000; font-weight: bold;">/</span>cfg_dropbear
<span style="color: #c20cb9; font-weight: bold;">chmod</span> u+x cfg_dropbear</pre></div></div>

<p>After downloading, the server has to be installed on the usbstick by executing</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>cfg_dropbear usb_install</pre></div></div>

<p>In my case the software is installed into <code class="path">/var/media/ftp/FLASH-DISK-01/addons</code>. Now we will create a host key which will be reused even after a reboot of the FRITZ!Box.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons
dropbear<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dropbearkey <span style="color: #660033;">-t</span> rsa <span style="color: #660033;">-f</span> dropbear<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sshd_rsa_host_key</pre></div></div>

<p>The FRITZ!Box has initial no root password entry. We have to create one and save the password hash for later usage.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">passwd</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span></pre></div></div>

<p>You have to note the part between <em>root:</em> and the next <em>colon</em>.</p>
<h2>Putting all together</h2>
<p>The initial starting point for all modifications on the FRITZ!Box is a file called <code class="path">/var/flash/debug.cfg</code>. Its executed on every boot after all the other services are started. We will use it only to start a script which is located on the usbstick. This makes sure that even after a firmware upgrade our changes are not lost. The content looks like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># execute the start script which is on the usb stick</span>
<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons<span style="color: #000000; font-weight: bold;">/</span>startup.sh</pre></div></div>

<p>Please note that you have to use the <code>nvi</code> to edit files on the flash device from the FRITZ!Box, cause all files there are marked as non regular. The <code class="cmd">startup.sh</code> will do all the work necessary for preparing and starting the ssh server. The content is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># whats the base usb directory</span>
<span style="color: #007800;">BASE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>FLASH-DISK-01<span style="color: #000000; font-weight: bold;">/</span>addons
&nbsp;
<span style="color: #666666; font-style: italic;"># change to a temporary directory</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
&nbsp;
<span style="color: #666666; font-style: italic;"># install and start dropbear with our host key</span>
<span style="color: #800000;">${BASE}</span><span style="color: #000000; font-weight: bold;">/</span>cfg_dropbear usb_install
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dropbear <span style="color: #660033;">-E</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${BASE}</span><span style="color: #000000; font-weight: bold;">/</span>dropbear<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sshd_rsa_host_key
&nbsp;
<span style="color: #666666; font-style: italic;"># set passwords</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'root:XXXXXX:0:0:root:/var/tmp/:/bin/sh'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'ftpuser:any:1000:0:ftp user:/var/media/ftp:/bin/sh'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># add fritz box itself in resolv.conf to resolv dhcp attached machines in your network</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;nameserver 192.168.220.1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>resolv.conf</pre></div></div>

<p>You have to replace XXXXXX by the password hash you created above. In my case the network is in the 192.168.220.0/24 subnet and the FRITZ!Box has the IP 192.168.220.1. You have to adjust the name server entry to your environment. After a reboot which could be initiated with <code>reboot</code> you should be able to access your FRITZ!Box over ssh.</p>
<p>To allow connections from the outside of your home you need to change the forward rules of the internal FRITZ!Box firewall. Unfortunately you can't add this rule using the web frontend cause it isn't allowed to add rules which targeting the FRITZ!Box itself. Most of the settings for the FRITZ!Box configuration are located in a file called <code class="path">/var/flash/ar7.cfg</code>. Use nvi to edit it and search for the string <strong>forwardrules</strong>. If this string is missing you could temporary create a rule in the web frontend, which will you later remove again. You have to change the line so that it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">forwardrules</span> <span style="color: #000066; font-weight:bold;">=</span>
               <span style="color: #933;">&quot;tcp 0.0.0.0:7777 0.0.0.0:22 0 # SSH-Server&quot;</span><span style="color: #666666; font-style: italic;">;</span></pre></div></div>

<p>Here the connection port is 7777, but of course could you use any valid port number. You could also add more rules by separating them with a comma. To make the configuration change happen the execution of <code class="cmd">ar7cfgchanged</code> is sufficient.</p>
<h2>Conclusion</h2>
<p>With this setup its possible to connect to the FRITZ!Box with the very secure ssh protocol from inside of your home environment and from the outside. This makes it easily possible to change parameters without manually starting the telnet daemon which is in addition very insecure. Don't forget to remove any temporary rules from the ar7.cfg file and to disable the telnet daemon with the procedure explained above. Stay tuned for the <a href="http://www.64k-tec.de/2010/02/fritzbox-tuning-part-2-access-your-home-network-with-openvpn/">next post</a> about going one step further and making the FRITZ!Box an OpenVPN connection point for your internal network.</p>
<h2>Update</h2>
<p>There is a new article about installing ssh on the FRITZ!Box. If you are interested have a look at <a href="http://www.64k-tec.de/2011/07/fritzbox-tuning-part-4-cross-building-and-installing-additional-applications/">this post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.64k-tec.de/2010/01/fritzbox-tuning-part-1-enable-remote-access-over-ssh/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

