<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Last Monkey</title>
	<atom:link href="https://thelastmaimou.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://thelastmaimou.wordpress.com</link>
	<description>A place where Amedio and I are equal</description>
	<lastBuildDate>Tue, 22 Apr 2014 21:37:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">51469225</site><cloud domain='thelastmaimou.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s0.wp.com/i/buttonw-com.png</url>
		<title>The Last Monkey</title>
		<link>https://thelastmaimou.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://thelastmaimou.wordpress.com/osd.xml" title="The Last Monkey" />
	<atom:link rel='hub' href='https://thelastmaimou.wordpress.com/?pushpress=hub'/>
	<item>
		<title>Picryption: TrueCrypt for the Pi</title>
		<link>https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/</link>
					<comments>https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Mon, 07 Apr 2014 17:12:00 +0000</pubDate>
				<category><![CDATA[Journey to the Clouds]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Raspbian]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[TrueCrypt]]></category>
		<category><![CDATA[TrueCrypt automount]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=784</guid>

					<description><![CDATA[Journey to the Clouds series. 3. Encrypting an external USB drive using TrueCrypt. TrueCrypt allows full disk encryption and we are going to use it to encrypt the USB drive attached to the Raspberry Pi so you can happily carry it around when needed. This post will also present two solutions for auto-mounting TrueCrypt volumes. &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p style="text-align:right;"><em>Journey to the Clouds series.<br />
3. Encrypting an external USB drive using TrueCrypt.</em></p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/04/picryption.gif"><img src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/04/picryption.gif?w=400&#038;h=300" alt="picryption" width="400" height="300" class="aligncenter" /></a><br />
TrueCrypt allows full disk encryption and we are going to use it to encrypt the USB drive attached to the Raspberry Pi so you can happily carry it around when needed. This post will also present two solutions for auto-mounting TrueCrypt volumes. We will use the latest version available, for that we will have to compile it from source and since the target is a headless Raspberry Pi we will compile it without graphical support.<br />
<span id="more-784"></span><br />
<em>Journey to the Clouds index:</em></p>
<ol>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/" title="Headless Pi Mess: Installing Raspbian">Install Raspbian on a headless Raspberry Pi.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/" title="Find Pi Everywhere: FreeDNS a free Dynamic DNS service">Configuring Dynamic DNS using  FreeDNS.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/" title="Picryption: TrueCrypt for the Pi">Encrypting an external USB drive using TrueCrypt.</a></li>
<li>Setting up Nginx web server.</li>
<li>Setting up MySQL database.</li>
<li>Setting up PHP.</li>
<li>Installing ownCloud.</li>
</ol>
<p>The first question that comes to mind is why TrueCrypt? Because it works in Linux, Windows and Mac, since we are dealing with an external drive it is quite likely that, at some point, you would like to use it in another computer, therefore it is best if no matter the operating system you can access to it. The next question is, why on earth will you compile it? If you find a pre-compiled binary officially supported let me know. </p>
<p>The last philosophical issue to point out is how secure you want it to be. TrueCrypt uses passwords and  keyfiles, if you want to avoid user interaction and have the USB drive automatically mounted then the password will have to be stored locally in plain text. That is a big drawback but you will have to make your peace with it or mount the encrypted drive manually. Basically there are two scenarios where storing the password is a major disadvantage: someone steals your Raspberry Pi along with the drive plugged in or someone hacks into the root account of the Raspberry Pi and a later point steals the USB drive attached. The former scenario could be likely in a house break-in due to the small nature of the Pi, but the later usually involves pissing off your geeky revengeful friend (maybe you said that <a href="http://www.imdb.com/title/tt0303461/" title="Firefly" target="_blank">Firefly</a> deserved to be canceled? My advice, do not upset geeks with a lot of free time in their hands).</p>
<h2>1. Required packages.</h2>
<p>In order to compile TrueCrypt and use <a href="http://en.wikipedia.org/wiki/ExFAT" title="Extended File Allocation Table - Wikipedia" target="_blank">exFAT</a> or NTFS we need to install some packages:<br />
<tt>$ sudo apt-get install  nasm libwxgtk2.8-dev libfuse-dev libgtk2.0-dev ntfs-3g exfat-fuse exfat-utils  byobu</tt></p>
<p>What follows is an explanation of the packages.</p>
<ul>
<li><tt><strong>nasm libwxgtk2.8-dev libfuse-dev libgtk2.0-dev</strong></tt>: required to compile TrueCrypt, the last package <tt>libgtk2.0-dev</tt> will install a bunch of extra packages, do not be alarmed.
<li><tt><strong>ntfs-3g</strong></tt>: provides support for NTFS partitions.
<li><tt><strong>exfat-fuse exfat-utils</strong></tt>: provides support for exFAT partitions. I recommend exFAT over NTFS because, in my experience, the Linux NTFS driver is quite CPU hungry and the Raspberry Pi is not a abundant in that regard.
<li><tt><strong><a href="http://byobu.co/" title="byobu website" target="_blank">byobu</a></strong></tt>: a terminal multiplexer (<a href="http://linuxcommand.org/lc3_adv_termmux.php" title="Terminal Multiplexers - LinuxCommand.org" target="_blank">say what???</a>), this package is not actually needed but it can become quite handy. Let me explain, the compilation of TrueCrypt may take a while (~40 min.) therefore it would be a good idea to use a tool which allows us to start processes in a SSH session, close the session, reconnect in a later time and reattach again to the process you left running. In case the SSH connection drops the compilation process would continue instead of stopping, note that you could accomplish a similar behavior using the standard <a href="http://en.wikipedia.org/wiki/Nohup" title="nohup - Wikipedia" target="_blank">nohup</a>.
</ul>
<h2>2. Download necessary files.</h2>
<p>There are three sets of files to download: the TrueCrypt source code, the  wxWidgets source code and the <a href="http://en.wikipedia.org/wiki/PKCS_11" title="Public-Key Cryptography Standards #11 - Wikipedia" target="_blank">PKCS-11 headers</a>. I tried to compile TrueCrypt using the wxWidgets provided by Raspbian but no luck, so better download source code as it mentions the TrueCrypt&#8217;s README file. </p>
<p>Since it is a good idea to create a directory and store everything at the same location, create it and change to it:<br />
<tt>$ mkdir ~/truecrypt_files<br />
$ cd ~/truecrypt_files</tt></p>
<p>Download <strong>wxWidgets</strong>:<br />
<tt>$ wget <a href="https://sourceforge.net/projects/wxwindows/files/2.8.12/wxWidgets-2.8.12.tar.gz" rel="nofollow">https://sourceforge.net/projects/wxwindows/files/2.8.12/wxWidgets-2.8.12.tar.gz</a><br />
And extract it<br />
$ tar zxvf wxWidgets-2.8.12.tar.gz</tt></p>
<p>Download the <strong>PKCS-11 headers</strong> in a sub-directory:<br />
<tt>$ mkdir -p ~/truecrypt_files/pkcs<br />
$ wget -P ~/truecrypt_files/pkcs ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20/*.h</tt></p>
<p>Finally obtain the <strong>TrueCrypt source code</strong> for Linux. There is no direct link because you have to accept the license. Go to <a href="http://www.truecrypt.org/downloads2" title="TrueCrypt Source Code Download Page" target="_blank">TrueCrypt source code download page</a> and select Mac OS X / Linux (.tar.gz), accept the license and download it. Place the file into the Raspberry Pi in the folder we created above, you can use scp for such a task. For instance, if you downloaded the file in your local computer in the user&#8217;s Downloads folder:<br />
<tt><em>(your computer)</em> $ scp Downloads/TrueCrypt\ 7.1a\ Source.tar.gz pi@<font color="gray">IpAddressOfPi</font>:~/truecrypt_files</tt></p>
<p>Once the file is in the Raspberry Pi, extract it, remember to be in <tt>~/truecrypt_files</tt>:<br />
<tt>$ cd ~/truecrypt_files<br />
$ tar xvzf  TrueCrypt\ 7.1a\ Source.tar.gz</tt></p>
<h2>3. It&#8217;s compile time.</h2>
<p>As mentioned above, I will use <tt>byobu</tt>, this is the crash course: </p>
<ul>
<li> Execute <tt>byobu</tt> to start a new session.  </li>
<li> Execute any command you like, it will run inside this session.</li>
<li> Press F6 to detach from the running session.</li>
<li> Execute <tt>byobu</tt> to reattach again to the running session. </li>
</ul>
<p>Of course <a href="https://help.ubuntu.com/community/Byobu" title="byobu - Ubuntu Community Help" target="_blank">there is more</a> to it but if you only have one <tt>byobu</tt> session that&#8217;s enough. </p>
<p>Just for fun, you can measure the time it takes to compile the packages by appending Bash   <tt>'time'</tt> command at the beginning of each instruction:<br />
<tt>$ byobu<br />
$ cd ~/truecrypt_files/truecrypt-7.1a-source<br />
$ export PKCS11_INC="/home/pi/truecrypt_files/pkcs/"<br />
$ export WX_ROOT=/home/pi/truecrypt_files/wxWidgets-2.8.12<br />
$ time make NOGUI=1 WX_ROOT=/home/pi/truecrypt_files/wxWidgets-2.8.12 wxbuild<br />
$ time make NOGUI=1 WXSTATIC=1</tt></p>
<p>I hope everything went well and the compilation did succeed, you should have the TrueCrypt binary at <tt>~/truecrypt_files/truecrypt-7.1a-source/Main/truecrypt</tt>; as a root copy it to <tt>/usr/bin</tt> and assign proper ownership and permissions:<br />
<tt>$ sudo cp Main/truecrypt /usr/bin/<br />
$ sudo  chown root:root /usr/bin/truecrypt<br />
$ sudo  chmod 555 /usr/bin/truecrypt </tt></p>
<p>From now one we are going to extensively make use of sudo because many commands require root privileges. As usual, when a command needs to be executed as root it will be denoted by starting the line with <tt><strong>#</strong></tt> instead of <tt><strong>$</strong></tt>. You can either become root permanently by executing <tt>'sudo -i'</tt> or insert <tt>'sudo'</tt> at the beginning of each command as we have been doing so far.</p>
<h2>4. Let&#8217;s encrypt something.</h2>
<p>Plug the USB drive and find out its device name (e.g. use lsblk), in my case is /dev/sda.<br />
Create the TrueCrypt container (I will not use any <a href="http://www.truecrypt.org/docs/keyfiles" title="keyfiles - TrueCrypt documentation" target="_blank">keyfiles</a>):<br />
<tt>$ truecrypt --keyfiles="" --protect-hidden=no --filesystem=none --volume-type=normal --create /dev/sda1</tt> </p>
<p>You will be asked to select the encryption and hash algorithms to use and a passphrase.</p>
<p>Load the container, you will be prompted for the passphrase:<br />
<tt>$ truecrypt --keyfiles="" --protect-hidden=no --filesystem=none --volume-type=normal /dev/sda1 </tt></p>
<p>Format it using exFAT:<br />
<tt># mkfs.exfat -n DATA /dev/mapper/truecrypt1</tt></p>
<p>Or, if you prefer, format it using NTFS:<br />
<tt># mkfs.ntfs -L DATA --fast /dev/mapper/truecrypt1 </tt></p>
<p>Unmount it:<br />
<tt>$ truecrypt --dismount</tt></p>
<p>Our USB drive is encrypted and formatted, it is time to create a permanent mount point. I will use the directory <tt>/external</tt> and assign public access plus the <a href="http://en.wikipedia.org/wiki/Sticky_bit" title="Sticky Bit - Wikipedia" target="_blank">sticky bit</a>:<br />
<tt># mkdir /external<br />
# chmod 777 /external<br />
# chmod +t /external</tt></p>
<p>I will assume the filesystem used is exFAT if you are using NTFS replace <tt>'exfat'</tt> by <tt>'ntfs-3g'</tt>. Mount the TrueCrypt volume:<br />
<tt>$ truecrypt --verbose --keyfiles="" --protect-hidden=no --slot=1  --filesystem=exfat /dev/sda1 /external</tt></p>
<p>Do not use a password in the command line because it will show when listing the processes (ps -ef). If you want to write the password in the command line use the <a href="http://www.tldp.org/LDP/abs/html/here-docs.html" title="Advanced Bash-Scripting Guide: Chapter 19. Here Documents" target="_blank">here-documment</a> approach, e.g.:</p>
<pre class="brush: bash; title: ; notranslate">
truecrypt --verbose --keyfiles=&quot;&quot; --protect-hidden=no --slot=1  --filesystem=exfat /dev/sda1 /external &lt;&lt;EOF
HereWriteYourPassphrase
EOF
</pre>
<p>In that fashion the password will not show in the processes list still it will show in the command history. The best approach for not writing the password is to store it in a file owned by root and only accessible by him. At the beginning of this post I commented on the security risk of this approach however we cannot automate the process otherwise.<br />
<tt># echo 'HereWriteYourPassphrase' &gt; /etc/volume.password<br />
# chmod 600 /etc/volume.password<br />
# truecrypt --verbose --keyfiles="" --protect-hidden=no --slot=1  --filesystem=exfat /dev/sda1 /external &lt; /etc/volume.password</tt></p>
<h2>5. Don&#8217;t bother me: automating TrueCrypt mounting</h2>
<p>The big issue: how do we auto-start the TrueCrypt mounting process? Currently <a href="https://wiki.archlinux.org/index.php/TrueCrypt#Accessing_a_TrueCrypt_container_using_cryptsetup" title="Accessing a TrueCrypt container using cryptsetup - Arch Linux Wiki" target="_blank">cryptsetup is able to handle TrueCrypt containers</a> however support started on version 1.6 and unfortunately the version available in Raspbian is 1.4.3 therefore we need an ad-hoc solution. I am very generous and instead of one I will give you two, both retrieving the passphrase from external files. The first solution is the simplest, it uses the the command of the above section in a script. The second solution is a bit more complex but it is extensible, it will use a <a href="https://wiki.debian.org/LSBInitScripts" title="Init Script LSB (Linux Standards Base) compliant - Debian Wiki" target="_blank">LSB compliant init script</a>, storing the truecrypt information in <tt>/etc/fstab</tt>.</p>
<h3>5.1 Simplicity is beauty: simple auto-mount script.</h3>
<p>In this approach we&#8217;ll use a simple script which will contain all the information except the volume&#8217;s passphrase which will be stored in <tt>/etc/volume.password</tt>. When the script is invoked without any arguments or with <tt>'start'</tt> it will mount the TrueCrypt volume and it will unmount all TrueCrypt volumes when invoked with <tt>'stop'</tt>. Error messages, if any, will be logged in <tt>/var/log/messages</tt>. </p>
<p><tt><strong>/etc/init.d/simplemounttruecrypt.sh</strong></tt></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh
#
# Usage: simplemounttruecrypt.sh [start|stop]
#   no argument | start: Mount a truecrypt volume
#   stop:  Unmount all truecrypt volumes
#
# On success do not print any message
# On failure:
#      1. Record the failure in the temporal file /tmp/truecrypt.error
#      2. Append the error message along with the timestamp to /var/log/messages
#      3. Delete the file temporal file /tmp/truecrypt.error
PROTECT_HIDDEN=no
KEYFILES=&quot;&quot;
SLOT=1
#FILESYSTEM=ntfs-3g
FILESYSTEM=exfat
VOLUME_PATH=/dev/sda1
MOUNT_DIRECTORY=/external
PASSWORD_FILE=/etc/volume.password

EXITSTATUS=0
case &quot;$1&quot; in
  ''|start)
    truecrypt \
      --verbose \
      --keyfiles=$KEYFILES \
      --protect-hidden=$PROTECT_HIDDEN \
      --slot=$SLOT  \
      --filesystem=$FILESYSTEM $VOLUME_PATH $MOUNT_DIRECTORY \
      &lt; $PASSWORD_FILE \
      &gt;/tmp/truecrypt.error 2&gt;&amp;1 \
    || EXITSTATUS=1 
    action=mounting
    ;;
  stop)
    truecrypt --dismount &gt;/tmp/truecrypt.error 2&gt;&amp;1 \
    || EXITSTATUS=1 
    action=unmounting
   ;;
  *)
    echo &quot;Usage: $0 [start|stop]&quot;
    exit 3
    ;;
esac

if [ $EXITSTATUS -ne 0 ]; then 
  echo &quot;$(date +&quot;%b %_d %T&quot;) $(hostname) $0: ERROR $action device: $(cat /tmp/truecrypt.error)&quot; &gt;&gt; /var/log/messages
fi

rm -f /tmp/truecrypt.error 2&gt;/dev/null
exit $EXITSTATUS
</pre>
<p>Assign proper permissions and add it to the <a href="https://www.debian-administration.org/article/212/An_introduction_to_run-levels" title="An introduction to run-levels - Debian Administration" target="_blank">run levels</a>:<br />
<tt># chmod 755 /etc/init.d/simplemounttruecrypt.sh<br />
# insserv simplemounttruecrypt.sh</tt><br />
When executing <tt>insserv</tt> you may see several warnings because this script, and possible others, are not LSB compliant.</p>
<p>In order to remove the scripts from the init system execute:<br />
<tt># insserv --remove simplemounttruecrypt.sh</tt><br />
The flag <tt>-f</tt> forces the services remove even if the files still exist in <tt>/etc/init.d</tt></p>
<h3>5.2 Automating better: data, logic &amp; LSB.</h3>
<p>The previous script is good enough to work with however the script itself contains the information of the TrueCrypt volume. It would be better to separate the data (the info about the TrueCrypt volume) from the logic (the process to mount it). By doing so we can easily extend it to be able to handle any number of TrueCrypt volumes without modifying the logic and only adding more entries to the data files. Since we are in the improving path, we will enhance the script&#8217;s output by using the following <a href="http://www.xensoft.com/content/use-exec-direct-all-bash-script-output-file-syslog-or-other-command" title="Use exec to direct all BASH script output to a file, syslog, or other command - xensoft " target="_blank">trick</a>: if it is invoked from a terminal it will output to the screen however if it is invoked by the system then the output will be redirected to the system log <tt>/var/log/messages</tt>. Finally, let&#8217;s also make it <a href="https://wiki.debian.org/LSBInitScripts" title="Init Script LSB (Linux Standards Base) compliant - Debian Wiki" target="_blank">LSB compliant</a>.</p>
<p>These are the three files used in this approach:</p>
<ul>
<li><tt>/etc/init.d/mounttruecrypt.sh</tt><br />
Script which mounts all truecrypt volumes defined in <tt>/etc/fstab</tt> using the passphrases stored in <tt>/etc/truecrypt.pass</tt><br />
The script will also unmount all truecrypt volumes.</p>
<li><tt>/etc/truecrypt.pass</tt><br />
File,  which should be accessible only by root (i.e. <tt>chmod 600</tt>), containing a passphrase per volume using the following syntax:<br />
<tt>device:Passprhase</tt><br />
Example:<br />
<tt>/dev/sda1:This is a very good passphrase 49373!@#@!.;Mono</tt></p>
<li><tt>/etc/fstab</tt><br />
As you know, this file defines the filesystems, we are going to <strong>append</strong> the TrueCrypt definitions using the following syntax:<br />
<tt>##truecrypt:device  mountPoint  filesystemType  filesystemMountOptions</tt><br />
Example using exFAT without any extra options:<br />
<tt>##truecrypt:/dev/sda1   /external   exfat</tt>
</ul>
<p>Note that due to the use of <tt>fstab</tt> and <tt>truecrypt.pass</tt> we could add as many entries as we like without modifying the script. In fact, the script will walk through the <tt>'##truecrypt:'</tt> entries of <tt>fstab</tt>, retrieve the device name and fetch the passphrase for such a device from <tt>truecrypt.pass</tt>. You can read the logic below.</p>
<p><strong><tt>/etc/init.d/mounttruecrypt.sh</tt></strong></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
### BEGIN INIT INFO
# Provides:          mounttruecrypt.sh 
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mount/unmount truecrypt volumes from /etc/fstab
# Description:       on start  mounts the truecrypt 
#                        - volumes are specified in /etc/fstab 
#                        - passwords are defined in  /etc/truecrypt.pass
#                    on shutdown unmount all truecrypt volumes, not only the specified by fstab
#
#                    The entries of /etc/fstab must start by '##truecrypt:'
#                    Entries can be commented by introducing an extra #, i.e. ###truecrypt
#                    The rest of the line is the same as a fstab entry
#                    ##truecrypt:VOLUME_PATH  MOUNT_DIRECTORY   FILESYSTEM  options
#                    Example:
#                    ##truecrypt:/dev/sda1   /external   ntfs-3g options
#
#                    /etc/truecrypt.pass must contain a single line for entry with the format:
#                    volume_path:password
#                    Example
#                    /dev/sda1:MySuperPassphrase
#                    Make sure /etc/truecrypt.pass has permission 600
### END INIT INFO


#VARIABLES for the truecrypt volume
PROTECT_HIDDEN=no
KEYFILES=&quot;&quot;
PASSWORD_FILE=/etc/truecrypt.pass

mount_all(){
    slot=0
    while read line; 
    do 
        read -a fields &lt;&lt;&lt; $line
        VOLUME_PATH=${fields[0]}
        MOUNT_DIRECTORY=${fields[1]}
        FILESYSTEM=${fields[2]}
        OPTIONS=${fields[3]}
        slot=$((slot+1))

        truecrypt \
          --text \
          --verbose \
          --keyfiles=$KEYFILES \
          --protect-hidden=$PROTECT_HIDDEN \
          --slot=${slot} \
          --fs-options=$OPTIONS \
          --filesystem=$FILESYSTEM $VOLUME_PATH $MOUNT_DIRECTORY \
          &lt; &lt;(grep $VOLUME_PATH $PASSWORD_FILE | sed &quot;s,^${VOLUME_PATH}:,,&quot;)  \
          | grep -v &quot;Enter password for&quot;

    done &lt; &lt;(grep '^##truecrypt' /etc/fstab | sed 's/##truecrypt://g')

}
# Function to redirect the output to syslog 
log_to_syslog(){
    # Temporal file for a named pipe
    script_name=$(basename &quot;$0&quot;)
    named_pipe=$(mktemp -u --suffix=${script_name}.$$)
    
    # On exit clean up
    trap &quot;rm -f ${named_pipe}&quot; EXIT

    # create the named pipe
    mknod ${named_pipe} p

    # start syslog and redirect the named pipe
    # append the script name before the messages
    logger &lt;${named_pipe} -t $0 &amp;

    # Redirect stout and stderr to the named pipe
    exec 1&gt;${named_pipe} 2&gt;&amp;1
}

# If the script does not run on a terminal then use syslog
set_log_output(){
    if [ ! -t 1 ]; then
        log_to_syslog    
    fi
}

case &quot;$1&quot; in 
    ''|start)
        EXITSTATUS=0
        set_log_output
        mount_all || EXITSTATUS=1
        exit $EXITSTATUS
        ;;
    stop)
        EXITSTATUS=0
        set_log_output
        truecrypt --verbose --dismount || EXITSTATUS=1
        exit $EXITSTATUS
        ;;
    restart|force-reload)
        EXITSTATUS=0
        $0 stop || EXITSTATUS=1
        $0 start || EXITSTATUS=1
        exit $EXITSTATUS
        ;;
    status)
        EXITSTATUS=0
        truecrypt --list 2&gt;/dev/null || echo &quot;No truecrypt volumes mounted&quot;
        exit $EXITSTATUS
        ;;
    *)
        echo &quot;Usage: $0 [start|stop|restart]&quot;
        exit 3
        ;;
esac
</pre>
<p>Assign the appropriate permissions and add the service:<br />
<tt># chmod 755 /etc/init.d/mounttruecrypt.sh<br />
# insserv /etc/init.d/mounttruecrypt.sh</tt></p>
<p>In order to remove the service:<br />
<tt># insserv --remove /etc/init.d/mounttruecrypt.sh</tt></p>
<p>By the way, if you have tried the <tt>simplemounttruecrypt.sh</tt> script and you want to use/try this new one remember to remove the previous:<br />
<tt># insserv --remove simplemounttruecrypt.sh</tt> </p>
<p>The End.</p>
<p>In the next chapter we will set up the Nginx web server.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">784</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/04/picryption.gif" medium="image">
			<media:title type="html">picryption</media:title>
		</media:content>
	</item>
		<item>
		<title>Find Pi Everywhere: FreeDNS a free Dynamic DNS service</title>
		<link>https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/</link>
					<comments>https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/#comments</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Sun, 23 Mar 2014 10:08:02 +0000</pubDate>
				<category><![CDATA[Journey to the Clouds]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Raspbian]]></category>
		<category><![CDATA[Dynamic DNS]]></category>
		<category><![CDATA[FreeDNS]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=703</guid>

					<description><![CDATA[Journey to the Clouds series. 2. Configuring Dynamic DNS using FreeDNS. Dynamic DNS is what allows common mortals to have a domain name without paying for a static IP address. Why FreeDNS? Because it is free of charge, you only need an email address to register and to update the IP address it is as &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p style="text-align:right;"><em>Journey to the Clouds series.<br />
2. Configuring Dynamic DNS using FreeDNS.</em></p>
<p><a href="https://play.google.com/store/apps/details?id=org.androidsoft.games.memory.tux"><img data-attachment-id="704" data-permalink="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/tuxmemorygame/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg" data-orig-size="495,271" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="tuxmemorygame" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg?w=495" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg?w=584" alt="tuxmemorygame"   class="aligncenter size-full wp-image-704" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg 495w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg?w=150&amp;h=82 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg?w=300&amp;h=164 300w" sizes="(max-width: 495px) 100vw, 495px" /></a><br />
<a href="http://en.wikipedia.org/wiki/Dynamic_DNS" title="Dynamic Domain Name System - Wikipedia" target="_blank">Dynamic DNS</a> is what allows common mortals to have a domain name without paying for a static IP address. Why FreeDNS? Because it is free of charge, you only need an email address to register and to update the IP address it is as easy as it gets: execute a command. I will walk you through the process to create a domain and configure the Pi to update the IP address when needed.<br />
<span id="more-703"></span><br />
<em>Journey to the Clouds index:</em></p>
<ol>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/" title="Headless Pi Mess: Installing Raspbian">Install Raspbian on a headless Raspberry Pi.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/" title="Find Pi Everywhere: FreeDNS a free Dynamic DNS service">Configuring Dynamic DNS using  FreeDNS.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/" title="Picryption: TrueCrypt for the Pi">Encrypting an external USB drive using TrueCrypt.</a></li>
<li>Setting up Nginx web server.</li>
<li>Setting up MySQL database.</li>
<li>Setting up PHP.</li>
<li>Installing ownCloud.</li>
</ol>
<p>As you know, <a href="http://en.wikipedia.org/wiki/Domain_Name_System" title="Domain Name System - Wikipedia" target="_blank">Domain Name System</a> (DNS) converts names into IP addresses. Every time you connect to a web server you type a name (i.e. google.com) but you actually connect to an IP address (i.e. 74.125.28.105) behind the scenes the names are converted to an IP address so you don&#8217;t need to remember any number but just a catchy name. In that sense, the IP address is like the phone number of your router, so a DNS will act as a telephone listing where you look up for a specific name and it will tell you the associated &#8220;phone number&#8221;. Usually residential connections do not have a static IP address, that is, every now and then your IP address will change, thus dynamic. If you want to have a domain name you need to update the IP associated to it every time in changes, so it can be located; that is the objective of the Dynamic DNS providers, they keep the association Domain Name&harr;IP address up to date. </p>
<p>Less chit-chat and more chop-chop, head to the <a href="https://freedns.afraid.org/" title="FreeDNS site" target="_blank">FreeDNS site</a> and at the bottom of the page click on &#8220;<a href="https://freedns.afraid.org/signup/" title="Create new account in FreeDNS" target="_blank">Sign Up!</a>&#8221; you will be presented with the following screen:</p>
<p><a href="http://freedns.afraid.org/signup/"><img data-attachment-id="715" data-permalink="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/freedns_subdomain_signup_1/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg" data-orig-size="756,743" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="freedns_subdomain_signup_1" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg?w=584" alt="freedns_subdomain_signup_1"   class="aligncenter size-full wp-image-715" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg?w=640&amp;h=629 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg?w=150&amp;h=147 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg?w=300&amp;h=295 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg 756w" sizes="(max-width: 640px) 100vw, 640px" /></a><br />
Once you fill it up, wait for the activation email and then you are set to go. To create a domain name click on &#8220;<a href="http://freedns.afraid.org/domain/registry/" title="Register a new domain in FreeDNS" target="_blank">Registry</a>&#8221; in the left menu. You will be presented with a list of possible server names, as shown below, choose the one you like most, note that your domain will be a sub-domain of the chosen one, that is, if you choose &#8220;<em>info.tm</em>&#8221; your domain will be &#8220;<em>something.info.tm</em>&#8220;.</p>
<p><a href="http://freedns.afraid.org/domain/registry/"><img data-attachment-id="717" data-permalink="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/freedns_subdomain_new_1/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg" data-orig-size="687,744" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="freedns_subdomain_new_1" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg?w=277" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg?w=584" alt="freedns_subdomain_new_1"   class="aligncenter size-full wp-image-717" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg?w=640&amp;h=693 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg?w=139&amp;h=150 139w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg?w=277&amp;h=300 277w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg 687w" sizes="(max-width: 640px) 100vw, 640px" /></a><br />
Leave &#8216;<em>Type</em>&#8216; as it is, the IP address should be already there, you only need to come up with a good domain name. In the example above I wrote &#8220;<em>raspberry.liar</em>&#8221; because I am planing to have other <em>XXX.liar</em> domains, but you could simply write a name without any dots. </p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg"><img loading="lazy" data-attachment-id="718" data-permalink="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/freedns_subdomain_new_2/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg" data-orig-size="829,744" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="freedns_subdomain_new_2" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=584" alt="freedns_subdomain_new_2"   class="aligncenter size-full wp-image-718" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=640&amp;h=574 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=150&amp;h=135 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=300&amp;h=269 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg?w=768&amp;h=689 768w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg 829w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>OK, you created your domain and now what? How does FreeDNS work? How does it update your IP address? FreeDNS assigns a unique identifier, a hash key, to your domain, when you want to update the IP your send a HTTP request along with your hash key. When FreeDNS receives such a request, it retrieves the IP address of the system sending the request (your router) and it updates it in its database for the associated hash key. The simple HTTP request have the following structure:<br />
<tt><font color="green">http&#058;//freedns.afraid.org/dynamic/update.php</font>?<font color="blue"><strong>HASHKEY</strong></font></tt></p>
<p>Therefore in order to update the IP we only need to send that sort of request when needed, that can be accomplished in different ways but in my opinion the easiest is to use <tt>wget</tt> in a <tt>cron</tt> job, both standard programs in all Linux systems therefore no extra packages are needed.</p>
<p>How do you find out which is your hash key? Click on &#8216;<a href="http://freedns.afraid.org/dynamic/" title="Dynamic DNS - FreeDNS member area" target="_blank">Dynamic DNS</a>&#8216;, scroll down to the bottom of the page until you see the domain you created, right click on &#8216;<tt>Direct URL</tt>&#8216; and copy the link location.</p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png"><img loading="lazy" data-attachment-id="723" data-permalink="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/freedns_subdomain_update_1/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png" data-orig-size="1079,658" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="freedns_subdomain_update_1" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=584" alt="freedns_subdomain_update_1"   class="aligncenter size-full wp-image-723" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=640&amp;h=390 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=150&amp;h=91 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=300&amp;h=183 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=768&amp;h=468 768w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png?w=1024&amp;h=624 1024w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png 1079w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>Paste the link in a text file and you will see something like:<br />
<tt><font color="black">http&#058;//freedns.afraid.org/dynamic/update.php</font>?<font color="blue"><strong>c29Q2s1Ml9df604bba2b1359ff62MTEyMT185e7=</strong></font></tt></p>
<p>The blue string is your hash key. Indeed if you (left) click on such link the IP will be updated, you can also execute <tt>wget</tt> to update the IP:<br />
<tt>$ wget -q --read-timeout=0.0 --waitretry=5 --tries=400 http&#058;//freedns.afraid.org/dynamic/update.php?<font color="blue">c29Q2s1Ml9df604bba2b1359ff62MTEyMT185e7=</font></tt></p>
<p>Let&#8217;s have a command like that being executed by <tt>cron</tt> every five minutes. The following script will be a <tt>cron</tt> job that when started it will check the public IP address of the Pi, then check the IP address of your domain, if they don&#8217;t match it will send the HTTP request to FreeDNS to update it. All the actions are logged in <tt>/var/log/messages</tt>. </p>
<p><tt>Script <em>/etc/cron.d/freedns_update.sh</em> replace DOMAIN and HASHKEY with your own values. </tt></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh
# freedns_update.sh: Update the public IP on freedns.afraid.org only if it has changed.
## Place this script in the cron's job directory /etc/cron.d and assign the proper permissions
## and owner
## sudo chmod 500 /etc/cron.d/freedns_update.sh
## sudo chown root:root /etc/cron.d/freedns_update.sh
## Add to /etc/crontab to execute on reboot and every 5 minutes
## Edit /etc/crontab and append these two lines:
## @reboot root /etc/cron.d/freedns_update.sh &gt;/dev/null
## */5 * * * * root /etc/cron.d/freedns_update.sh &gt;/dev/null

#Use your own values
DOMAIN=raspberry.liar.info.tm
HASHKEY=c29Q2s1Ml9df604bba2b1359ff62MTEyMT185e7=

UPDATE_URL=&quot;http://freedns.afraid.org/dynamic/update.php?${HASHKEY}&quot;
   
current_ip=$(wget -q --output-document - http://checkip.dyndns.org | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
registered_ip=$(ping -qn -c 1 $DOMAIN | head -n 1 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')

if [ &quot;${current_ip}&quot; != &quot;${registered_ip}&quot; ]; then   
   wget -q --read-timeout=0.0 --waitretry=5 --tries=400 --output-document /dev/null $UPDATE_URL
   if [ $? -eq 0 ]; then
     echo &quot;$(date +&quot;%b %_d %T&quot;) $(hostname) $0: IP address updated on freedns.afraid.org: new IP '${current_ip}', old IP '${registered_ip}'&quot; &gt;&gt; /var/log/messages
   else     
     echo &quot;$(date +&quot;%b %_d %T&quot;) $(hostname) $0: ERROR IP address could not be  updated on freedns.afraid.org: current IP '${current_ip}', registered IP '${registered_ip}'&quot; &gt;&gt; /var/log/messages
   fi
fi
</pre>
<p>As stated in the above script&#8217;s comments, create the script in /etc/cron.d, set the owner and permissions:<br />
<tt>$ sudo chmod 500 /etc/cron.d/freedns_update.sh<br />
$ sudo chown root:root /etc/cron.d/freedns_update.sh</tt></p>
<p>In order to execute every time the Raspberry Pi reboots and every 5 minutes append these two lines to <tt>/etc/crontab</tt><br />
<tt></p>
<pre style="background-color:#f0f0f0;color:black;">
@reboot root /etc/cron.d/freedns_update.sh &gt;/dev/null
*/5 * * * * root /etc/cron.d/freedns_update.sh &gt;/dev/null
</pre>
<p></tt></p>
<p>Finally you have to configure your router to <a href="http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/" title="How To Forward Ports on Your Router -  How-To Geek" target="_blank">forward the ports</a> you want to the Raspberry Pi. At this time only the SSH server is active so add a rule to forward whichever public port you like to private port 22 of the Raspberry Pi IP address. Once we set up the Nginx web server then you will also have to redirect the ports 80 and 443 but for now it is not needed not recommended.</p>
<p>For instance if you have set the public SSH port to be <font color="blue">4563</font> then you can connect, and follow the rest of the steps, by<br />
<tt>$ ssh pi@raspberry.liar.info.tm -p <font color="blue">4563</font></tt></p>
<p>Remember you can always <a href="https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/" target="_blank">add the appropriate entries to <tt>~/.ssh/config</tt></a>.</p>
<p>In the <a href="https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/" title="Picryption: TrueCrypt for the Pi">next chapter</a> we will install TrueCrypt version 6 and encrypt a USB drive, see you around.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">703</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/tuxmemorygame.jpg" medium="image">
			<media:title type="html">tuxmemorygame</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_signup_1.jpeg" medium="image">
			<media:title type="html">freedns_subdomain_signup_1</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_1.jpeg" medium="image">
			<media:title type="html">freedns_subdomain_new_1</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_new_2.jpeg" medium="image">
			<media:title type="html">freedns_subdomain_new_2</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/freedns_subdomain_update_1.png" medium="image">
			<media:title type="html">freedns_subdomain_update_1</media:title>
		</media:content>
	</item>
		<item>
		<title>Headless Pi Mess: Installing Raspbian</title>
		<link>https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/</link>
					<comments>https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Sat, 22 Mar 2014 20:15:17 +0000</pubDate>
				<category><![CDATA[Journey to the Clouds]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Raspbian]]></category>
		<category><![CDATA[headless]]></category>
		<category><![CDATA[static IP]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=655</guid>

					<description><![CDATA[Journey to the Clouds series. 1. Install Raspbian on a headless Raspberry Pi. In this post we will install Raspbian, a Debian based distro, in the Raspberry PI. Usually I&#8217;d go for Arch Linux but for this project I will side with Debian because the lower frequency of updates and therefore less maintenance once it &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p style="text-align:right;"><em>Journey to the Clouds series.<br />
1. Install Raspbian on a headless Raspberry Pi.</em></p>
<p><img class="aligncenter" alt="headless" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/headless.png?w=400&#038;h=283" width="400" height="283" /><br />
In this post we will install <a href="http://www.raspbian.org/" target="_blank">Raspbian</a>, a Debian based distro, in the Raspberry PI. Usually I&#8217;d go for Arch Linux but for this project I will side with Debian because the lower frequency of updates and therefore less maintenance once it is up and running. As a downside we will have to install TrueCrypt, PHP, Nginx and ownCloud either from source either from their repositories to take advantage from the latest packages.<br />
<span id="more-655"></span><br />
<em>Journey to the Clouds index:</em></p>
<ol>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/" title="Headless Pi Mess: Installing Raspbian">Install Raspbian on a headless Raspberry Pi.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/" title="Find Pi Everywhere: FreeDNS a free Dynamic DNS service">Configuring Dynamic DNS using  FreeDNS.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/" title="Picryption: TrueCrypt for the Pi">Encrypting an external USB drive using TrueCrypt.</a></li>
<li>Setting up Nginx web server.</li>
<li>Setting up MySQL database.</li>
<li>Setting up PHP.</li>
<li>Installing ownCloud.</li>
</ol>
<p>I will use my Linux box to flush the image onto the SD card and to connect to the Raspberry Pi through SSH, but you could use whatever OS that lets you sleep at night. Especially for the part of writing the Raspbian image onto the SD card, remember <a title="Google is your friend" href="http://www.giyf.com/" target="_blank">GIYF</a>.</p>
<p>Grab the image from the <a href="http://www.raspberrypi.org/downloads" target="_blank">Raspbian downloads site</a>, at the time of writing this post the latest image is &#8216;2014-01-07-wheezy-raspbian&#8217; and the direct links are the ones shown below:</p>
<ul>
<li>Image <a href="http://downloads.raspberrypi.org/raspbian_latest" rel="nofollow">http://downloads.raspberrypi.org/raspbian_latest</a></li>
<li>Torrent <a href="http://downloads.raspberrypi.org/raspbian_latest.torrent" rel="nofollow">http://downloads.raspberrypi.org/raspbian_latest.torrent</a></li>
<li>SHA-1 Checksum 9d0afbf932ec22e3c29d793693f58b0406bcab86</li>
<li>Default login pi / raspberry</li>
</ul>
<p>Once you get the image, verify the image with the SHA1 signature:<br />
<tt>$ sha1sum -c &lt;(echo "9d0afbf932ec22e3c29d793693f58b0406bcab86 2014-01-07-wheezy-raspbian.zip")</tt></p>
<p>If you would like to optimize the SD card read this <a title="Optimizing Arch Linux Image Installation on the Raspberry Pi" href="https://thelastmaimou.wordpress.com/2013/05/19/optimizing-arch-linux-image-installation-on-the-raspberry-pi/" target="_blank">previous entry</a> otherwise flush the image as described below.</p>
<p>Plug the SD card into your computer and find out the device name. In my opinion the easiest way it to execute <tt>lsblk</tt>, plug the SD card, execute again <tt>lsblk</tt> and spot the differences. However feel free to use <tt>fdisk -l</tt>, inspect the journal (<tt>journalctl -f</tt>) or the messages file for non-systemd (<tt>tailf /var/log/messages</tt>) or even use a graphical application like <a href="http://gparted.org/" target="_blank">GParted</a>. Whichever method you choose just make sure it is the SD card, don&#8217;t come crying later on if you messed it up.</p>
<p>In my case the SD card is assigned to <tt>/dev/sdb</tt>. In the following commands notice I am using the whole device (<tt>/dev/sdb</tt>) and <strong>not</strong> the partition (<tt>/dev/sdb<span style="color:blue;"><strong>1</strong></span></tt>). If you have enough free RAM unzip on the fly and flush it all at once:<br />
<tt>$ gunzip -c 2014-01-07-wheezy-raspbian.zip | sudo dd of=/dev/sdb bs=64K</tt></p>
<p>Otherwise do it in two steps or it will hog your computer:<br />
<tt>$ gunzip -k -S .zip 2014-01-07-wheezy-raspbian.zip<br />
$ sudo dd if=2014-01-07-wheezy-raspbian of=/dev/sdb bs=1M</tt></p>
<p>If you want to monitor the progress you can open a new terminal, find out the <a title="Process Identifier - Wikipedia" href="http://en.wikipedia.org/wiki/Process_identifier" target="_blank">PID</a> of the <tt>dd</tt> command and send the USR1 signal to it. The output will show in the terminal where <tt>dd</tt> was launched.<br />
<tt>$ sudo watch kill -USR1 $(pidof dd)</tt></p>
<p>Next is to insert the SD into the Raspberry Pi but, since it is a headless installation, repress yourself from doing it just now and keep reading before proceeding. The way to find out the IP address of the Raspberry Pi is to list the IP addresses in your network before and after you connect it and compare the differences (the before-after-comparison again, it&#8217;s like the MAcGyver chewing gum). Of course you could always log into your router and see the connected devices if you prefer. If you, wisely, choose the path of the console, execute:</p>
<pre class="brush: bash; title: ; notranslate">
dirA=$(fping -i 10 -r 1 -aAgq 192.168.1.0/24 | tee /dev/tty) &amp;&amp; \
echo -e &quot;\nPlug the Raspberry Pi, wait at least one minute and press enter&quot;; read novar &amp;&amp; \
dirB=$(fping -i 10 -r 1 -aAgq 192.168.1.0/24| tee /dev/tty) &amp;&amp; \
echo -e &quot;\nNew IP address found:&quot;; \
diff &lt;(echo &quot;$dirA&quot; | sort) &lt;(echo &quot;$dirB&quot; | sort) &amp;&amp; echo &quot;  |-&gt; None&quot;
</pre>
<p>As the black terminal says, and your are bound to obey because it is the <strong>black terminal</strong>, plug the Pi when it says so and wait for a minute, then hit enter. If everything went alright you should see the new IP. This is the output of my network:<br />
<tt></p>
<pre style="background-color:black;color:#00ff00;">192.168.1.1
192.168.1.19
192.168.1.12
192.168.1.20

Plug the Raspberry Pi wait at least for a minute and press enter

192.168.1.1
192.168.1.11
192.168.1.19
192.168.1.20
192.168.1.12

New IP address found:
1a2
&gt; 192.168.1.11</pre>
<p></tt><br />
Log into the Pi and finish the installation. As it was shown earlier, the default login for the image we installed is username: pi and password: raspberry<br />
<tt>$ ssh pi@192.168.1.11<br />
$ sudo raspi-config</tt><br />
<a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/raspi-config.png"><img src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/raspi-config.png?w=600&#038;h=226" alt="raspi-config" width="600" height="226" class="aligncenter" /></a></p>
<pre style="background-color:#e0ffe0;color:black;"><em>Essential adjustments:</em>
1 Expand Filesystem
3 Enable Boot to Desktop/Scratch
  |→ Console Text console, requiring login (default)
8 Advanced Options 
  |→ A3 Memory Split → 16

<em>Recommended adjustments:</em>
2 Change User Password
4 Internationalisation Options 
  |→ I2 Change Timezone
8 Advanced Options 
  |→ A2 Hostname

<em>To my taste:</em>
4 Internationalisation Options 
  |→ I1 Change Locale
      <strong>-</strong> deselect en_GB.UTF-8 UTF-8  
      <strong>+</strong> select en_US.UTF-8 UTF-8
      <strong>→</strong> Default locale for the system environment: en_US.UTF-8</pre>
<p>Before rebooting, one final thing is to <a title="Debian Network Configuration: Configuring the interface manually" href="https://wiki.debian.org/NetworkConfiguration#Configuring_the_interface_manually" target="_blank">assign a static</a> IP to the Pi, for that edit <tt>/etc/network/interfaces</tt>, comment out the line <tt>'iface eth0 inet dhcp'</tt> and add the static definition. Below you have an example assigning the IP <span style="color:blue;">192.168.1.106</span> to the Raspberry and declaring that the router IP is <span style="color:green;">192.168.1.1</span><br />
<tt></p>
<pre style="background-color:#f0f0f0;color:black;"><em>Excerpt of /etc/network/interfaces</em>
#iface eth0 inet dhcp
iface eth0 inet static
   address <font color="blue">192.168.1.106</font>
   netmask 255.255.255.0
   gateway <font color="green">192.168.1.1</font>
</pre>
<p></tt><br />
If you don&#8217;t know how to edit that file type:<br />
<tt>$ sudo nano /etc/network/interfaces</tt><br />
Make the changes, save by pressing <tt>ctrl+o</tt> and exit by pressing <tt>ctrl+x</tt> (then <a href="http://www.youtube.com/watch?v=-qtrAMK7_Qk" title="Russell Peters: Be a Man " target="_blank">be a man</a> and <a href="http://vim-adventures.com/" title="Learn VIM playing a game - VIM Adventures" target="_blank">learn how</a> to use <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" title="Vi IMproved - Wikipedia" target="_blank">vi</a>).</p>
<p>Now you can reboot your Pi<br />
<tt>$ sudo reboot</tt></p>
<p>It is recommended to update the system after a fresh installation:<br />
<tt>$ sudo apt-get update &amp;&amp; sudo apt-get upgrade</tt></p>
<p>Sit back and triumphantly exhale, you&#8217;ve done it!!!!!!<br />
<a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg"><img loading="lazy" data-attachment-id="750" data-permalink="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/bart_sit_and_relax/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg" data-orig-size="367,246" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="Bart_sit_and_relax" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg?w=367" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg?w=584" alt="Bart_sit_and_relax"   class="aligncenter size-full wp-image-750" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg 367w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg?w=150&amp;h=101 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg?w=300&amp;h=201 300w" sizes="(max-width: 367px) 100vw, 367px" /></a></p>
<p>But as a bonus, let&#8217;s ingest a <a href="https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/" target="_blank">SSH candy</a> and configure the SSH connection to simplify future log ins from your Linux computer. The following is to be done in your Linux box, not in the Raspberry Pi. If you don&#8217;t have an authentication key pair yet, generate one:<br />
<tt>$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_raspbian</tt><br />
Copy the public key to the Pi<br />
<tt>$ ssh-copy-id -i ~/.ssh/id_rsa_raspbian.pub pi@192.168.1.106</tt><br />
Test that it works<br />
<tt>$ ssh pi@192.168.1.106</tt></p>
<p>Finally add the new entry in your SSH configuration file.<br />
<tt></p>
<pre style="background-color:#f0f0f0;color:black;"><em>Excerpt of ~/.ssh/config</em>
# Entry for the Raspberry Pi
Host pi_root
  User root #by default root access is not permitted in Raspbian
Host pi 
  User pi
Host pi pi_root 
  HostName 192.168.1.106
  IdentityFile ~/.ssh/id_rsa_raspbian

#Default values to all connections
Host *
  ForwardAgent yes
  ForwardX11 yes
  PubkeyAuthentication yes</pre>
<p></tt><br />
From now on, we can simply log in by typing<br />
<tt>$ ssh pi</tt></p>
<p>In the <a href="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/" title="Find Pi Everywhere: FreeDNS a free Dynamic DNS service">next chapter</a> we will configure Dynamic DNS to access the Raspberry Pi from everywhere.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">655</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/headless.png" medium="image">
			<media:title type="html">headless</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/raspi-config.png" medium="image">
			<media:title type="html">raspi-config</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/bart_sit_and_relax.jpg" medium="image">
			<media:title type="html">Bart_sit_and_relax</media:title>
		</media:content>
	</item>
		<item>
		<title>Journey to the Clouds: Launching a Headless Raspbian</title>
		<link>https://thelastmaimou.wordpress.com/2014/03/22/journey-to-the-clouds-launching-a-headless-raspbian/</link>
					<comments>https://thelastmaimou.wordpress.com/2014/03/22/journey-to-the-clouds-launching-a-headless-raspbian/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Sat, 22 Mar 2014 20:14:44 +0000</pubDate>
				<category><![CDATA[Journey to the Clouds]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Raspbian]]></category>
		<category><![CDATA[FreeDNS]]></category>
		<category><![CDATA[LEMP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[ownCloud]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[TrueCrypt]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=637</guid>

					<description><![CDATA[In these posts series we will set up ownCloud on top of a LEMP stack, that is Linux (Raspbian), Nginx, MySQL and PHP. The storage to be used will be an USB drive encrypted using TrueCrypt and we will achieve Dynamic DNS through FreeDNS. With such a configuration we will get our very own Dropbox &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2014/03/22/journey-to-the-clouds-launching-a-headless-raspbian/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p><img src="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/raspberry-launch.png?w=400&#038;h=250" alt="Launching Raspberries" width="400" height="250" class="aligncenter" /><br />
In these posts  series we will set up <a href="http://owncloud.org/" target="_blank">ownCloud</a> on top of a LEMP stack, that is Linux (<a href="http://www.raspbian.org/" target="_blank">Raspbian</a>), <a href="http://nginx.org/" target="_blank">Nginx</a>, <a href="http://www.mysql.com/" target="_blank">MySQL</a> and <a href="http://www.php.net/" target="_blank">PHP</a>. The storage to be used will be an USB drive encrypted using <a href="http://www.truecrypt.org/" target="_blank">TrueCrypt</a> and we will achieve Dynamic DNS through <a href="https://freedns.afraid.org/" target="_blank">FreeDNS</a>. With such a configuration we will get our very own <a href="https://www.dropbox.com/" target="_blank">Dropbox</a>  replacement that we will be able to control as we pleased. All that on a headless Pi, that is, no need for monitor nor screen. The only thing to do is to insert the SD card, the USB drive and connect it to the router.</p>
<ol>
<em>Journey to the Clouds index:</em></p>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/" title="Headless Pi Mess: Installing Raspbian">Install Raspbian on a headless Raspberry Pi.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/03/23/find-pi-everywhere-freedns-a-free-dynamic-dns-service/" title="Find Pi Everywhere: FreeDNS a free Dynamic DNS service">Configuring Dynamic DNS using  FreeDNS.</a></li>
<li><a href="https://thelastmaimou.wordpress.com/2014/04/07/picryption-truecrypt-for-the-pi-2/" title="Picryption: TrueCrypt for the Pi">Encrypting an external USB drive using TrueCrypt.</a></li>
<li>Setting up Nginx web server.</li>
<li>Setting up MySQL database.</li>
<li>Setting up PHP.</li>
<li>Installing ownCloud.</li>
</ol>
<p><span id="more-637"></span><br />
Using TrueCrypt has some caveats but it is compatible with all major operating systems, so you can always unplug the USB drive from the Raspberry Pi and plug it into a Windows computer with no much hassle. </p>
<p>The decision to use Nginx instead of Apache is due to the lightweight nature of the former, thus lower RAM consumption. More on that when we address its installation. </p>
<p>For the Dynamic DNS there are plenty of providers, some free of charge, some charging a little and some free of charge under certain conditions. FreeDNS has no charge at all and it only requires an email address to register.  The Dynamic DNS configuration could definitely be the last topic but maybe you are going to find yourself away from the little Pi and you would like to guarantee remote access without having to ask your cat to tell you its IP address.  </p>
<p>So let&#8217;s start&#8230; in the <a href="https://thelastmaimou.wordpress.com/2014/03/22/headless-pi-mess-installing-raspbian/" title="Headless Pi Mess: Installing Raspbian">next chapter</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2014/03/22/journey-to-the-clouds-launching-a-headless-raspbian/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">637</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2014/03/raspberry-launch.png" medium="image">
			<media:title type="html">Launching Raspberries</media:title>
		</media:content>
	</item>
		<item>
		<title>Are those processes talking to you? Kill them all!</title>
		<link>https://thelastmaimou.wordpress.com/2013/11/16/are-those-processes-talking-to-you-kill-them-all/</link>
					<comments>https://thelastmaimou.wordpress.com/2013/11/16/are-those-processes-talking-to-you-kill-them-all/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Sat, 16 Nov 2013 11:26:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[kill]]></category>
		<category><![CDATA[PGID]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=595</guid>

					<description><![CDATA[This is not a very known feature of the killing command but it is possible to kill a process along with all its children, this is very convenient when a script spawns into several processes and you want to terminate all of them at once. The key is to pass the PGID (the process group &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2013/11/16/are-those-processes-talking-to-you-kill-them-all/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p style="text-align:center;"><img src="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/11/tux_rambo.png?w=584" alt="Tux Rambo" /></p>
<p>This is not a very known feature of the killing command but it is possible to kill a process along with all its children, this is very convenient when a script spawns into several processes and you want to terminate all of them at once.<br />
The <a href="http://linux.die.net/man/1/kill" title="Kill Manual Page" target="_blank">key</a> is to pass the <a href="http://www.win.tue.nl/~aeb/linux/lk/lk-10.html" title="Processes, The Linux kernel by Andries Brouwer" target="_blank">PGID</a> (the process group ID) with a minus sign in front:<br />
<tt>$ kill -9 -PGID<br />
$ kill -- -PGID</tt></p>
<p>Use <tt>'ps -j'</tt> to list the processes&#8217; PGIDs. <span id="more-595"></span></p>
<p>In the first example the SIGKILL (9) signal is sent to all the processes belonging to the process group ID denoted by PGID. When using PGID you must state the signal to be sent, if you want to send the default TERM (15) signal then you can use a double hyphen <tt>'--'</tt> as shown in the second example.</p>
<p>How does it work? Well, the first created  process has as PGID the same value as its <a href="http://en.wikipedia.org/wiki/Process_identifier" title="Process Identifier, Wikipedia" target="_blank">PID</a> (process ID), afterwards each newly created child-process will inherit the PGID of the parent. Therefore, the most of the times you can simply execute:<br />
&nbsp;&nbsp;<em><tt>kill -- -{PID_of_the_first_process}</tt></em></p>
<p>To list the processes&#8217; PPID and PGID use the command <tt>ps</tt> with the flags <tt>-f</tt> and <tt>-j</tt> respectively. </p>
<p>Let&#8217;s see a very simple example. We&#8217;ll create a C program that the only thing it does is to delay for some seconds and then call such program from a couple of scripts. These are the listings:</p>
<p><strong>test.c</strong></p>
<pre class="brush: cpp; title: ; notranslate">main(){
    sleep(600);
}</pre>
<p><strong>parent.sh</strong></p>
<pre class="brush: bash; title: ; notranslate">#!/bin/bash
./test parent &amp;
./test parent &amp;
./child.sh </pre>
<p><strong>child.sh</strong></p>
<pre class="brush: bash; title: ; notranslate">#!/bin/bash
./test child &amp;
./test child &amp;
./test child</pre>
<p>Open a terminal, compile the C program and execute the <tt>parent.sh</tt> script:<br />
<tt>$ gcc -o test test.c<br />
$ ./parent.sh</tt></p>
<p>Now, in another terminal let&#8217;s see the processes:<br />
<tt>$ ps -efj | grep '[U]ID\|[p]arent\|[c]hild'<br />
UID&nbsp;&nbsp;&nbsp;&nbsp;PID&nbsp;&nbsp;PPID PGID SID&nbsp;&nbsp;C STIME TTY&nbsp;&nbsp;&nbsp;TIME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CMD<br />
stewie   <font color="green">4562</font>  3715  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 /bin/bash ./parent.sh<br />
stewie   4563  <font color="green">4562</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test parent<br />
stewie   4564  <font color="green">4562</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test parent<br />
stewie   <font color="blue">4565</font>  <font color="green">4562</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 /bin/bash ./child.sh<br />
stewie   4566  <font color="blue">4565</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test child<br />
stewie   4567  <font color="blue">4565</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test child<br />
stewie   4568  <font color="blue">4565</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test child<br />
</tt><br />
What do we see here? We have two Bash scripts and five <tt>'test'</tt> programs running. The <tt>parent.sh</tt> has PID  <font color="green">4562</font> which is the PGID of all the processes. Note that the <tt>'test'</tt> programs started by <tt>'child.sh'</tt> have a different PPID but the same PGID. If we wanted to terminate all the processes at once, it would not work to kill the parent process you can verify this by executing <tt>kill</tt> on the <tt>parent.sh</tt> PID:</p>
<p><tt>$kill <font color="green">4562</font><br />
$ ps -efj | grep '^[U]ID\|[p]arent\|[c]hild'<br />
UID&nbsp;&nbsp;&nbsp;&nbsp;PID&nbsp;&nbsp;PPID PGID SID&nbsp;&nbsp;C STIME TTY&nbsp;&nbsp;&nbsp;TIME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CMD<br />
stewie   4563 &nbsp;&nbsp;&nbsp;1  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test parent<br />
stewie   4564 &nbsp;&nbsp;&nbsp;1  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test parent<br />
stewie   <font color="blue">4565</font> &nbsp;&nbsp;&nbsp;1  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 /bin/bash ./child.sh<br />
stewie   4566  <font color="blue">4565</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test child<br />
stewie   4567  <font color="blue">4565</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test child<br />
stewie   4568  <font color="blue">4565</font>  <font color="green">4562</font>  3715  0 14:07 pts/6    00:00:00 ./test child</tt></p>
<p>Only <tt>parent.sh</tt> was terminated, the rest of processes are still alive. Try now to use the PGID instead:<br />
<tt>$ kill -- -<font color="green">4562</font><br />
$ ps -efj | grep '^[U]ID\|[p]arent\|[c]hild'<br />
UID        PID  PPID  PGID   SID  C STIME TTY          TIME CMD<br />
</tt><br />
Now we have killed them all, and yes, we are bad asses.</p>
<p>Finally, it is worth noting that your shell may have a built-in <tt>kill</tt> command, in fact the most common shells like bash, dash, mksh, zsh, tcsh do have it. If <tt>kill</tt> does not behave as expected it may be due to that and you should call <tt>kill</tt> using the full path (use <tt>which</tt> to determine it). The only universal way I am aware of for finding out if a command is built-in is to read the manual page (e.g. man bash); however shells usually have utilities to query the nature of a command, here is a small list</p>
<table style="border:none;">
<tr>
<td style="border:none;">bash: </td>
<td style="border:none;">type -a kill</td>
</tr>
<tr>
<td style="border:none;">mksh: </td>
<td style="border:none;">type -a kill (type is equivalent to whence -v)</td>
</tr>
<tr>
<td style="border:none;">zsh: </td>
<td style="border:none;">type kill (type is equivalent to whence -v)</td>
</tr>
<tr>
<td style="border:none;">dash: </td>
<td style="border:none;">type kill</td>
</tr>
<tr>
<td style="border:none;">tcsh:</td>
<td style="border:none;"> where kill</td>
</tr>
<table>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2013/11/16/are-those-processes-talking-to-you-kill-them-all/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">595</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/11/tux_rambo.png" medium="image">
			<media:title type="html">Tux Rambo</media:title>
		</media:content>
	</item>
		<item>
		<title>This GRUB does not start (in Ubuntu)</title>
		<link>https://thelastmaimou.wordpress.com/2013/11/11/this-grub-does-not-start-in-ubuntu/</link>
					<comments>https://thelastmaimou.wordpress.com/2013/11/11/this-grub-does-not-start-in-ubuntu/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Mon, 11 Nov 2013 08:32:14 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[GRUB_RECORDFAIL_TIMEOUT]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=588</guid>

					<description><![CDATA[This is the situation, for some unfortunate reason your Ubuntu system crashed, maybe there was a black out, maybe your cat seeking more attention unplugged the computer. In any case, at some point the computer is switched back on but it does not automatically start, it stays in the GRUB&#8217;s selection menu waiting for any &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2013/11/11/this-grub-does-not-start-in-ubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>This is the situation, for some unfortunate reason your Ubuntu system crashed, maybe there was a black out, maybe your cat seeking more attention unplugged the computer. In any case, at some point the computer is  switched back on but it does not automatically start, it stays in the GRUB&#8217;s selection menu waiting for any entity, usually a humanoid form of it, to hit enter. <span id="more-588"></span></p>
<p>That&#8217;s fine if it is your main computer, but what about if it a headless server in the other side of the city (or the room)? Well, this falls in the category of &#8220;not a bug but an undocumented feature&#8221; kind of thing. To be  all fair, it is somehow documented <a href="https://help.ubuntu.com/community/Grub2#Last_Boot_Failed_or_Boot_into_Recovery_Mode">here</a>, long story short, in Ubuntu after a failed boot/crash GRUB is designed to stay in the selection menu.  Is there a way to disable such a behavior? </p>
<p>The <a href="https://help.ubuntu.com/community/Grub2#Last_Boot_Failed_or_Boot_into_Recovery_Mode">Ubuntu documentation</a> explains the old way to get rid of this &#8220;feature&#8221;. From 12.04 (Precise Pangolin) and above, there is a simpler way, that is to define the <tt>GRUB_RECORDFAIL_TIMEOUT</tt> variable in <tt>/etc/default/grub</tt>:</p>
<ul>
<li><tt>GRUB_RECORDFAIL_TIMEOUT=0</tt> # disables the menu, boots right away</li>
<li><tt>GRUB_RECORDFAIL_TIMEOUT=-1</tt> # waits until the user selects an entry, default behavior</li>
<li><tt>GRUB_RECORDFAIL_TIMEOUT=XX</tt> # XX in seconds, waits for that amount of time before proceeding </li>
</ul>
<p>After modifying <tt>/etc/default/grub</tt> you will have to update grub configuration file, as root:<br />
<tt>$ sudo update-grub</tt></p>
<p>By the way, as far as I have seen this affects only the Ubuntu family, the original GRUB package does not provide this behavior, in fact, <tt>GRUB_RECORDFAIL_TIMEOUT</tt> is not part of the <a href="http://www.gnu.org/software/grub/manual/grub.html#Configuration">GRUB&#8217;s configuration options</a>, Ubuntu modifies it to support this functionality.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2013/11/11/this-grub-does-not-start-in-ubuntu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">588</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>
	</item>
		<item>
		<title>Listing built-in modules</title>
		<link>https://thelastmaimou.wordpress.com/2013/07/11/listing-built-in-modules/</link>
					<comments>https://thelastmaimou.wordpress.com/2013/07/11/listing-built-in-modules/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Thu, 11 Jul 2013 09:29:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[/proc/config.gz]]></category>
		<category><![CDATA[built-in module]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[modules.builtin]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=525</guid>

					<description><![CDATA[Have you ever wondered how to list the built-in kernel modules? Here you are, they are in the file modules.builtin. Now it is easy to check if a module is built-in or not, grep will suffice: $grep module_name /lib/modules/$(uname -r)/modules.builtin Too short? OK keep reading for a longer modules&#8217; tale. As you already know, the &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2013/07/11/listing-built-in-modules/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>Have you ever wondered how to list the built-in kernel modules? Here you are, they are in the file <a href="https://www.kernel.org/doc/Documentation/kbuild/kbuild.txt">modules.builtin</a>. Now it is easy to check if a module is built-in or not, <code>grep</code> will suffice:<br />
<code>$grep module_name /lib/modules/$(uname -r)/modules.builtin</code></p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg"><img loading="lazy" data-attachment-id="550" data-permalink="https://thelastmaimou.wordpress.com/2013/07/11/listing-built-in-modules/wall-e-rubiks-cube3/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg" data-orig-size="1907,839" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="wall-e-rubiks-cube3" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=584" class="alignnone size-full wp-image-550" alt="wall-e-rubiks-cube3" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=584"   srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=640&amp;h=282 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=1280&amp;h=563 1280w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=150&amp;h=66 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=300&amp;h=132 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=768&amp;h=338 768w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg?w=1024&amp;h=451 1024w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>Too short? OK keep reading for a longer modules&#8217; tale. <span id="more-525"></span><br />
As you already know, the Linux kernel is the software that controls the computer&#8217;s hardware and it is composed by an essential core and optional modules. These optional modules, sort of &#8220;add-ons&#8221;, expand the kernel capabilities and give support to a big variety of hardware, for instance a webcam or a scanner. The modules can be statically built into the kernel or <a href="https://en.wikipedia.org/wiki/Loadable_kernel_module">dynamically loadable</a>.</p>
<p>The external loadable modules are usually located under <code>/usr/lib/modules/</code> in a directory named after the kernel released, therefore in order to list it use <code>'uname -r'</code>:<br />
<code>$ ls /usr/lib/modules/$(uname -r)</code></p>
<p>These kind of modules can be loaded (<code>modprobe</code>), unloaded (<code>rmmod</code>) and listed (<code>lsmod</code>). On the other hand, built-in modules do no accept any of those actions. They are always loaded, they cannot be unloaded and they cannot be listed. Being always loaded does not mean they are always active (in use), a module can be loaded but it will be active only when it is required. For example, suppose that your webcam&#8217;s module is built-in, then it will always be loaded but only active (being used) when a program (e.g. Skype) uses the webcam.</p>
<p>Part of the kernel building process is to configure it, that is, to select which features we will activate or deactivate, for that matter a configuration file is used defining for each feature if it will be enabled or not. There is no one-to-one correspondence between features and modules; a feature may have associated zero, one or more modules. For instance, the <a href="http://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem support requires the single module <code>ext4</code> but the <a href="http://cateee.net/lkddb/web-lkddb/X86_UV.html">support for SGI Ultraviolet</a> systems requires 5 modules (<code>tlb_uv</code>, <code>bios_uv</code>, <code>uv_irq</code>, <code>uv_sysfs</code>, <code>uv_time</code>).<br />
For each feature the configuration file define three possible values:</p>
<ul>
<li><code>"y"</code>: the feature is enabled, all associated modules will be built-in.</li>
<li><code>"m"</code>: the feature is enabled, all associated modules will be externally loadable.</li>
<li>not enabled: the feature will not be supported, this state is indicated either by removing the entire line either by commenting it out with &#8220;#&#8221;</li>
</ul>
<p>It is quite common for the different Linux distros to distributed this configuration file along with the kernel, this is normally done either as a regular file either under the (runtime) <a href="http://en.wikipedia.org/wiki/Procfs">/proc filesystem</a>.</p>
<p><em><strong>Regular file</strong></em><br />
This is the approach <a href="http://wiki.debian.org/KernelFAQ#Misc_FAQ">followed by Debian</a> and its derivatives (like Ubuntu). The kernel package includes the text file <code>/boot/config-$(uname -r)</code>, for example to query if the kvm_intel feature is enabled:<br />
<code>$ grep -i kvm_intel /boot/config-$(uname -r) </code></p>
<p><em><strong>/proc filesystem</strong></em><br />
Many other distributions, like Arch Linux, enable the <a href="http://cateee.net/lkddb/web-lkddb/IKCONFIG_PROC.html">option</a> to include the <a href="http://www.linuxinsight.com/proc_config.gz.html">running kernel configuration</a> within the <a href="http://en.wikipedia.org/wiki/Procfs">/proc filesystem</a>. In this case the file is a compressed text file located at <code>/proc/config.gz</code>, you can use the <code>zcat/zgrep</code> utilities to inspect it; for instance:<br />
<code>$ zgrep -i kvm_intel /proc/config.gz </code></p>
<p>The final piece of the puzzle is to establish the relationship between features and kernel modules. Bad news: this relationship is not stored anywhere. <a href="http://www.youtube.com/watch?v=1D1cap6yETA">Good news everyone</a>: you can obtain the info from the Linux source code. In the Linux sources, the <a href="http://unix.stackexchange.com/questions/38023/binding-lsmod-module-name-with-kernel-configuration-menu-entry">MakefileS contain lines such as</a>:<br />
<code>obj-$(CONFIG_XXX) += module_1.o module_2.o </code></p>
<p>As you may have guessed, the above line means that the feature &#8216;<em>XXX</em>&#8216; requires the modules &#8216;<em>module_1</em>&#8216; and &#8216;<em>module_2</em>&#8216;, therefore creating your local &#8220;<em>database</em>&#8221; is simply a grep command:<br />
<code>$ cd /path/to/linux/sources<br />
$ grep -R --include=Makefile 'obj-$(CONFIG_.*\.o.*' . | sort -u &gt; feature_modules.txt</code></p>
<p>Now you can easily look for modules and features:<br />
<code>$ grep CONFIG_ZRAM feature_modules.txt<br />
./drivers/staging/zram/Makefile:obj-$(CONFIG_ZRAM) += zram.o</code></p>
<p>As a side note I will add that <a href="https://www.kernel.org/doc/Documentation/kbuild/kbuild.txt">modprobe will not fail when loading a built-in kernel</a> hence another (empirical) way to assert if a module is built-in consist in loading the module using <code>modprobe</code> and if it does not fail then try to list it using <code>lsmod</code>, if the module is not listed then it is built in. In bash:<br />
<code>$ module=XXX;<br />
$ modprobe ${module} &amp;&gt;/dev/null; if [[ $? -ne 0 ]]; then echo module ${module} does not exist; elif [[ $(lsmod | grep -cw ${module}) -eq 0 ]]; then echo ${module} is built-in; else echo ${module} is loadable module, NOT built-in;fi</code></p>
<p>That was a long mambo-jumbo but is there any practical application in all this? Why should you care if a module is built-in or not? That&#8217;s a good question and the answer is: let&#8217;s hope you don&#8217;t need it. This is another tool for troubleshooting so unless something is not working you should not care. A scenario could be when something in your computer (e.g. the Wi-Fi) does not work in <em>distro-1</em> (e.g. Debian) but it works in another <em>distro-2</em> (e.g. <a href="http://www.knopper.net/knoppix/index-en.html">Knoppix</a>), so you think it is a module issue and decide to compare between both distros the loaded modules to find out which is one you are missing. Such an attempt will fail if the Wi-Fi module is built-in as it will not be listed in <code>lsmod</code> and you will just get crazy wondering which spell distro-2 casts for the Wi-Fi to work.</p>
<p style="text-align:center;"><img loading="lazy" data-attachment-id="562" data-permalink="https://thelastmaimou.wordpress.com/2013/07/11/listing-built-in-modules/tux_palantil/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png" data-orig-size="1235,752" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="tux_palantil" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=584" class="aligncenter size-full wp-image-562" alt="tux_palantil" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=584"   srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=396&amp;h=241 396w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=792&amp;h=482 792w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=150&amp;h=91 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=300&amp;h=183 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png?w=768&amp;h=468 768w" sizes="(max-width: 396px) 100vw, 396px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2013/07/11/listing-built-in-modules/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">525</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/wall-e-rubiks-cube3.jpg" medium="image">
			<media:title type="html">wall-e-rubiks-cube3</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/07/tux_palantil1.png" medium="image">
			<media:title type="html">tux_palantil</media:title>
		</media:content>
	</item>
		<item>
		<title>SSH candies: config, copy-id, keygen.</title>
		<link>https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/</link>
					<comments>https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/#respond</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Sun, 16 Jun 2013 05:39:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[multi-hop]]></category>
		<category><![CDATA[ProxyCommand]]></category>
		<category><![CDATA[ssh-copy-id]]></category>
		<category><![CDATA[ssh-keygen]]></category>
		<category><![CDATA[ssh_config]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=352</guid>

					<description><![CDATA[There is a time when being cool it is simply too much work. Sure we all want to impress a newbie by typing long cryptic commands in a black screen and then say “I&#8217;m in”, but at the end of the day, let&#8217;s accept it, we don&#8217;t have many visitors except the little nephews who &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>There is a time when being cool it is simply too much work. Sure we all want to impress a newbie by typing long cryptic commands in a black screen and then say “I&#8217;m in”, but at the end of the day, let&#8217;s accept it, we don&#8217;t have many visitors except the little nephews who are lurking around trying to use our machines to surf porn. In this post we&#8217;ll see how to reduce our number of keystrokes when connecting through ssh by the usage of configuration files.</p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg"><img loading="lazy" data-attachment-id="383" data-permalink="https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/ssh_trinityreloaded/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg" data-orig-size="640,272" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="Trinity SSH" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg?w=584" alt="Trinity SSH"   class="alignnone size-full wp-image-383" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg?w=150&amp;h=64 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg?w=300&amp;h=128 300w" sizes="(max-width: 640px) 100vw, 640px" /></a><br />
<span id="more-352"></span><br />
As you know, ssh accepts many input parameters and usually you will type them in the command line, for instance:<br />
<tt>$ ssh -i <font color='BlueViolet'>~/.ssh/id_rsa_lab.pub</font> <font color='firebrick'>bender</font>@<font color='green'>10.1.1.42</font></tt></p>
<p>In the above example we are saying to ssh to connect to <tt>'<font color='green'>10.1.1.42</font>'</tt> using the username <tt>'<font color='firebrick'>bender</font>'</tt> and the keyfile <tt>'<font color='BlueViolet'>~/.ssh/id_rsa_lab.pub</font>'</tt>. All those options could be saved in the ssh configuration file and avoid typing them, so we can simply execute something like:<br />
<tt>$ ssh lab</tt></p>
<p>And so it begins. <a href="http://www.openssh.org/">OpenSSH</a> uses two default <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;sektion=5">configuration files</a> (<tt>/etc/ssh/ssh_config</tt> and <tt>~/.ssh/config</tt>) but you could use any file you like and pass it to ssh through the option  <tt>'-F'</tt>. The configurations options are loaded in the following order:</p>
<ol>
<li>Command line arguments, options passed directly to ssh when invoking it, for example <tt>ssh <b>-Y</b></tt>
<li>~/.ssh/config: user default configuration file, this file only applies to the current user.
<li>/etc/ssh/ssh_config: global file for all users and all connections; only the admin can modify it.
</ol>
<p><strong>Once a parameter is set its value will not change</strong>, in other words, if the same option is given multiple times with different values, ssh will use the first value and ignore the rest. Having that in mind it is easy to understand that command line arguments override the settings of the personal ssh configuration file (<tt>~/.ssh/config</tt>) which in turn also override the settings provided by the global configuration file (<tt>/etc/ssh/ssh_config</tt>). The same principle applies inside each configuration file  and therefore <strong>global settings should be always located at the end</strong> of the files.</p>
<p>The ssh configuration file is divided in entries, each entry sets the specific options for a given server and it starts by the keyword <tt>'<font color="red">Host</font>'</tt> followed by a name, that name will be the alias of the connection that you will use to invoke it. Actually, it is not a name but a <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;sektion=5#PATTERNS">pattern</a> so you could define entries like <tt>'Host lab*'</tt>, more on this in a second. If you want to specify <strong>global options for all the connections</strong> use the <tt>'*'</tt> wildcard, that is, <tt>'<strong>Host *</strong>'</tt>. As usual, comments are entered by &#8216;#&#8217; symbol and blank lines are ignored. </p>
<p>The following is a simple configuration file:</p>
<pre><code><tt><font color="red">Host</font> <font color="orange"><strong>lab</strong></font>
  <font color="RoyalBlue">HostName</font> <font color="green">10.1.1.42</font>
  <font color="RoyalBlue">User</font> <font color="firebrick">bender</font>
  <font color="RoyalBlue">PubkeyAuthentication</font> yes
  <font color="RoyalBlue">IdentityFile</font> <font color="BlueViolet">~/.ssh/id_rsa_lab</font>

<font color="olive"><em>#Options applicable to all connections</em></font>
<font color="red">Host</font> <font color="orange"><strong>*</strong></font>
    <font color="RoyalBlue">ForwardAgent</font> yes
    <font color="RoyalBlue">ForwardX11</font> yes
</tt></code></pre>
<p>The first entry (<tt><font color="red">Host</font> <font color="orange"><strong>lab</strong></font></tt>) sets the options to be used for the server denoted as <tt>'<font color="orange">lab</font>'</tt> the address is <font color="green">10.1.1.42</font>, the user name is <tt>'<font color="firebrick">bender</font>'</tt>, it should use public key authentication and the key is the file <tt>'<font color="BlueViolet">~/.ssh/id_rsa_lab</font>'</tt>.<br />
The second entry (<tt><font color="red">Host</font> <font color="orange"><strong>*</strong></font></tt>)  sets the parameters global to all connections, in this case: use X11 forwarding (so we can start graphical applications) and forward the ssh-agent credentials (that is for another post). </p>
<p>If now we want to connect to <font color="green">10.1.1.42</font> we will simply type:<br />
<tt>$ ssh <font color="orange">lab</font></tt><br />
which is equivalent to<br />
<tt>$ ssh -i <font color="BlueViolet">~/.ssh/id_rsa_lab</font> -X  <font color="firebrick">bender</font>@<font color="green">10.1.1.42</font></tt></p>
<p>Using <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;sektion=5#PATTERNS">patterns</a> we can avoid duplicate options, let&#8217;s say we want to define another connection to the same server <tt>'<font color="orange"><strong>lab</strong></font>'</tt> but for a different user, this time for <tt>root</tt>. We could create a new entry having all the same fields except <font color="RoyalBlue">User</font> or we could use a <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;sektion=5#PATTERNS">pattern</a> that will match both defintions. For instance, we can define <tt>'lab'</tt> for the regular user, <tt>'lab_root'</tt> for the root and use the pattern <tt>'lab<strong>*</strong>'</tt> for both. Remember to always put first specific options and then the more general ones.</p>
<pre><code><tt>
<font color="olive"><em>#Options only for the regular user</em></font>
<font color="red">Host</font> <font color="orange"><strong>lab</strong></font>
  <font color="RoyalBlue">User</font> <font color="firebrick">bender</font>
<font color="olive"><em>#Options only for root</em></font>
<font color="red">Host</font> <font color="orange"><strong>lab_root</strong></font>
  <font color="RoyalBlue">User</font> <font color="firebrick">root</font>
<font color="olive"><em>#Options applicable for both, the regular user and the root</em></font>
<font color="red">Host</font> <font color="orange"><strong>lab*</strong></font>
  <font color="RoyalBlue">HostName</font> <font color="green">10.1.1.42</font>
  <font color="RoyalBlue">PubkeyAuthentication</font> yes
  <font color="RoyalBlue">IdentityFile</font> <font color="BlueViolet">~/.ssh/id_rsa_lab</font>

<font color="olive"><em>#Options applicable to all connections</em></font>
<font color="red">Host</font> <font color="orange"><strong>*</strong></font>
    <font color="RoyalBlue">ForwardAgent</font> yes
    <font color="RoyalBlue">ForwardX11</font> yes
</tt></code></pre>
<p>To connect as a <tt>root</tt> simply type:<br />
<tt>$ ssh lab_root</tt></p>
<p>Most likely, you will be prompted for a password, this is normal, you need to install your public key into the target server. And this is what starts making all this very useful: <strong>all ssh programs will use the settings of the configuration files</strong>; from now on we will be very cheap with our keystrokes (saving them for important usage like playing <a href="https://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy_%28computer_game%29">HHGTTG</a>). If you don&#8217;t have a key pair yet it is time to generate the default set, to be honest, the key generation should have been the first step but that was a boring way to start a post. </p>
<p>Generating default RSA key pair:<br />
<tt>$ ssh-keygen -t rsa</tt><br />
This will generate the following keys:<br />
<tt>~/.ssh/id_rsa</tt>: private key, keep it safe.<br />
<tt>~/.ssh/id_rsa.pub</tt>: public key, which you will install onto the servers you want to connect to.</p>
<p>Note: if you enter a passphrase instead of leaving it blank then you should make use of <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh-agent&amp;sektion=1"><tt>ssh-agent</tt></a>. I&#8217;ll discuss passphrases and the ssh-agent in a following post.</p>
<p>Since I am bit paranoid, I usually create a key pair for each server I want to log into. For that you need to specify the output file otherwise the default keys (id_rsa, id_rsa.pub) will be overwritten. For example, for the server <tt>'<font color="orange"><strong>lab</strong></font>'</tt> I will generate:<br />
<tt>$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_<strong>lab</strong></tt><br />
This will generate the following keys:<br />
<tt>~/.ssh/id_rsa_<strong>lab</strong>: private key.</tt><br />
<tt>~/.ssh/id_rsa_<strong>lab</strong>.pub: public key to install in '<font color="orange"><strong>lab</strong></font>'</tt>.</p>
<p>Continue generating as many keys as your paranoia level dictates and lets you sleep at night. </p>
<p>The actual <strong>key installation</strong> consist in appending the public key to the file <tt>'~/.ssh/authorized_keys'</tt> of the target system, you can do this manually (by editing the file) or faster and easier by using <a href="http://linux.die.net/man/1/ssh-copy-id"><tt><strong>ssh-copy-id</strong></tt></a>:<br />
<tt>$ ssh-copy-id -i ~/.ssh/id_rsa_lab.pub <strong>lab</strong></tt><br />
This is equivalent to:<br />
<tt>$ cat ~/.ssh/id_rsa_lab.pub | ssh  bender@10.1.1.42 'cat &gt;&gt; ~/.ssh/authorized_keys'</tt></p>
<p>No passwords should be requested anymore when connecting to <tt>'<font color="orange"><strong>lab</strong></font>'</tt> or copying files to/from it. Try it by creating a file and copying it:<br />
<tt>$ touch test.txt<br />
$ scp test.txt <strong>lab</strong>:~/</tt></p>
<p>That was a very simple usage but yet it is very convenient. What else can you configure? Everything really, all the input parameters that ssh accepts can be statically set in the configuration files. To spice things up, let&#8217;s use the config file to define <strong>ssh multi-hop connections</strong>, that is to access a system through another system. Let&#8217;s take as an example my home set up.</p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png"><img loading="lazy" data-attachment-id="384" data-permalink="https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/house_net/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png" data-orig-size="1578,770" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="House network" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=584" alt="House network"   class="alignnone size-full wp-image-384" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=640&amp;h=312 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=1280&amp;h=625 1280w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=150&amp;h=73 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=300&amp;h=146 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=768&amp;h=375 768w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png?w=1024&amp;h=500 1024w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>As you can see from the above picture, in my house I have set up a PC (actually a virtual machine) named <tt>'firewall'</tt>  as the solely entry point to my network. In order to connect to the rest of systems I will always connect through <tt>'firewall'</tt> and therefore I only have to configure my router to open a single port instead of one port per machine. (The router should be configured to use <a href="http://en.wikipedia.org/wiki/Dynamic_DNS">dynamic DNS</a> and to forward all incoming traffic on port 40022 to 192.168.1.200 port 22).</p>
<p>If I intent to connect from the office or from a public place (e.g. a cafeteria), the entries for such a scenario will look like this:</p>
<pre><code><tt><font color="red">Host</font> <font color="GoldenRod"><strong>firewall</strong></font>
  <font color="RoyalBlue">HostName</font> <font color="green">firewall159357.dyndns.org</font>
  <font color="RoyalBlue">Port</font> 40022
  <font color="RoyalBlue">User</font> <font color="firebrick">cartman</font>
  <font color="RoyalBlue">PubkeyAuthentication</font> yes
  <font color="RoyalBlue">IdentityFile</font> <font color="BlueViolet">~/.ssh/id_rsa_firewall</font>

<font color="red">Host</font> <font color="orange"><strong>mycomputer</strong></font>
  <font color="RoyalBlue">HostName</font> <font color="green">192.168.1.201</font>
  <font color="RoyalBlue">User</font> <font color="firebrick">stewie</font>
  <font color="RoyalBlue">PubkeyAuthentication</font> yes
  <font color="RoyalBlue">IdentityFile</font> <font color="BlueViolet">~/.ssh/id_rsa_mycomputer</font>
  <font color="RoyalBlue"><strong>ProxyCommand</strong></font> ssh <font color="GoldenRod"><strong>firewall</strong></font> nc %h %p 2&gt;/dev/null

<font color="red">Host</font> <font color="orange"><strong>pi</strong></font>
  <font color="RoyalBlue">HostName</font> <font color="green">192.168.1.203</font>
  <font color="RoyalBlue">User</font> <font color="firebrick">raspberry</font>
  <font color="RoyalBlue">PubkeyAuthentication</font> yes
  <font color="RoyalBlue">IdentityFile</font> <font color="BlueViolet">~/.ssh/id_rsa_pi</font>
  <font color="RoyalBlue"><strong>ProxyCommand</strong></font> ssh <font color="GoldenRod"><strong>firewall</strong></font> nc %h %p 2&gt;/dev/null
</tt></code></pre>
<p>The first entry, <tt>'<strong>Host firewall</strong>'</tt>, defines how to access my LAN, it configures the connection to the machine <tt>'firewall'</tt>; this connection will be used by the rest of the entries. <tt>'<strong>Host mycomputer</strong>'</tt> specifies how to connect to my computer and <tt>'<strong>Host pi</strong>'</tt> how connect to the Raspberry Pi. The key here for the ssh multi-hop is the <tt>'<a href="http://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts#ProxyCommand_with_Netcat">ProxyCommand</a>'</tt> where we use <tt>'<a href="http://linux.die.net/man/1/nc">nc</a>'</tt> (<tt>netcat</tt>) to transparently send and receive data through a ssh connection. <tt>ProxyCommand</tt> is briefly explained in the <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;sektion=5">manual</a> page of <tt>ssh_config</tt> and <a href="http://www.hackinglinuxexposed.com/articles/20040830.html">this article</a> gives a very good explanation about the use of <tt>netcat</tt> and the <tt>ProxyCommand</tt>.</p>
<p>Installing now the public keys is a piece of cake:<br />
<tt>$ ssh-copy-id -i ~/.ssh/id_rsa_firewall.pub firewall<br />
$ ssh-copy-id -i ~/.ssh/id_rsa_mycomputer.pub  mycomputer<br />
$ ssh-copy-id -i ~/.ssh/id_rsa_pi.pub pi</tt></p>
<p>And to connect simply:<br />
<tt>$ ssh pi</tt><br />
Compare that with the cumbersome command line equivalent:<br />
<tt>$ ssh  -i ~/.ssh/id_rsa_pi -X  raspberry@192.168.1.203 -o '<font color="#555555">ProxyCommand ssh  -i ~/.ssh/id_rsa_firewall -X cartman@firewall159357.dyndns.org nc %h %p 2&gt;/dev/null</font>'</tt></p>
<p>Likewise, copying files is straight forward:<br />
<tt>$ scp localFile <strong>pi</strong>:~/remoteDirectory<br />
$ scp <strong>pi</strong>:~/remoteDirectory/remoteFile ~/localPath/</tt></p>
<p>It is clear the advantage of spending a bit of time setting your <tt>~/.ssh/config</tt>. Consult the manual (<a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;sektion=5"><tt>man ssh_config</tt></a>) for a complete list of available options. Of course, you should memorize all the full commands to be prepared for a zombie break out or simply to show off in front of lamers picking into your screen (in this latter case do not forget to lean back and loudly exhale saying &#8216;FBI here I am&#8217;). </p>
<p>Finally, as a sweet end of post, an <strong>easy way to remove stale entries from <tt>~/.ssh/known_hosts</tt> file</strong>. First of all, what is that file? For security reasons, the first time you connect to a server ssh will retrieve its digital fingerprint and store it in that file, afterwards every time you connect again to the same server, ssh  will dynamically retrieve the server&#8217;s fingerprint and compare it against  the stored value. If the values don&#8217;t match then ssh will refuse to proceed and it will abort. For a given system the digital fingerprint will always be the same, the problem arises when the same IP address refers to a different system, this is typically the case when you install a new operating system into the same machine and give the same IP address as it had before. In such an example the following will occur:</p>
<pre><tt>$ ssh pi
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
aa:df:df:57:53:4f:53:c2:a4:38:bf:b7:11:8d:4b:3e.
Please contact your system administrator.
Add correct host key in /home/bender/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/bender/.ssh/known_hosts:<font color="Fuchsia"><strong>2</strong></font>
ECDSA host key for <font color="DarkGreen"><strong>192.168.1.203</strong></font> has changed and you have requested strict checking.
<font color="red">Host key verification failed.</font>
</tt></pre>
<p>If you are certain the new fingerprint is valid then you should remove the entry for <tt><font color="DarkGreen"><strong>192.168.1.203</strong></font></tt> which corresponds to the line number <font color="Fuchsia"><strong>2</strong></font> of <tt>known_hosts</tt> (or alternatively, if you have no security concerns, become a Rambo and delete the whole file). You can edit the file with your favorite editor and remove such a line or you can <strong>use <tt>'sed'</tt></strong>:<br />
<tt>$ sed -i '<font color="Fuchsia"><strong>2</strong></font>d' ~/.ssh/known_hosts</tt><br />
I prefer to use the OpenSSH utility <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh-keygen&amp;sektion=1"><tt><strong>ssh-keygen</strong></tt></a>:<br />
<tt>$ ssh-keygen -R <font color="DarkGreen"><strong>192.168.1.203</strong></font></tt></p>
<p>Here is where we should all hail <tt>ssh-keygen</tt> obscurity! Who would think that a program named <tt>'-keygen'</tt> had the ability to remove anything? Anyway, that&#8217;s it.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2013/06/16/ssh-candies-config-copy-id-keygen/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">352</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/ssh_trinityreloaded.jpg" medium="image">
			<media:title type="html">Trinity SSH</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/06/house_net.png" medium="image">
			<media:title type="html">House network</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutti Frutti: 7zip + KDE + Arch Linux</title>
		<link>https://thelastmaimou.wordpress.com/2013/05/29/tutti-frutti-7zip-kde-arch-linux/</link>
					<comments>https://thelastmaimou.wordpress.com/2013/05/29/tutti-frutti-7zip-kde-arch-linux/#comments</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Wed, 29 May 2013 11:35:22 +0000</pubDate>
				<category><![CDATA[Arch Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[7zip]]></category>
		<category><![CDATA[p7zip]]></category>
		<category><![CDATA[pkgfile]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=337</guid>

					<description><![CDATA[I like 7zip, it is a free (LGPL), fast, simple but powerful, multi-platform file archiver (aka compressor). In every computer I use I always install it. Here is the thing, in Arch Linux under KDE it does not work out of the box (a penny for each time I say this sentence). It actually has &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2013/05/29/tutti-frutti-7zip-kde-arch-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>I like <a href="http://www.7-zip.org/">7zip</a>, it is a free (<a href="http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License">LGPL</a>), fast, simple but powerful, multi-platform <a href="File archiver">file archiver</a> (aka compressor). In every computer I use I always install it. Here is the thing, in Arch Linux under KDE it does not work out of the box (a penny for each time I say this sentence). It actually has two problems: it does not start (this is the main issue) and the Dolphin&#8217;s context (right-click) menu has duplicate entries. The later is simply annoying, the former is frustrating.</p>
<p>For the impatient archers:<br />
<tt># pacman -S wxgtk2.8<br />
# rm /usr/share/kde4/services/ServiceMenus/p7zip_compress2.desktop</tt></p>
<p><em>2014-04-22 Update: Originally this post mentioned the <tt>wxgtk</tt> package however currently the required package is <tt>wxgtk2.8</tt>. On 2014 Arch Linux, following upstream development, updated it from version 2.8 to version 3.0 but some applications, among them 7zip, still require the older 2.8 version to work and therefore the package <tt>wxgtk2.8</tt> was introduced.<br />
Thank you Tobias.<br />
</em><br />
<span id="more-337"></span><br />
For those who like to waste their time reading stupid troubleshooting stories because they don&#8217;t have other better things to do while their consoles update to the latest firmware, keep on.</p>
<p>The reason 7zip was not starting was a missing library, how do you find out? If you launch 7zip from the terminal you will get the following exotic error:<br />
<tt>$ 7zFM<br />
/usr/lib/p7zip/7zFM: <font color="red">error</font> while loading shared libraries: <font color="red">libwx_gtk2u_adv-2.8.so.0</font>: cannot open shared object file: <font color="red">No such file or directory</font></tt></p>
<p>This is one of the easiest troubleshooting cases, the error is telling us which library we miss. Next step is to find out where such a file resides; for such a task we will use <a href="https://wiki.archlinux.org/index.php/Pkgfile">pkgfile</a> (in Ubuntu/Debian the equivalent is called <a href="http://www.debian.org/doc/manuals/apt-howto/ch-search.en.html#s-apt-file">apt-file</a>). <a href="https://wiki.archlinux.org/index.php/Pkgfile">pkgfile</a>  creates a database with all the packages&#8217; files therefore you can search afterwards which package provides file X (<a href="http://www.youtube.com/watch?v=HQoRXhS7vlU">tururururuuuuuuu</a>).</p>
<p>If you don&#8217;t have it installed yet, you know what to do:<br />
<tt># pacman -S pkgfile</tt><br />
Update the database, that is, let <a href="https://wiki.archlinux.org/index.php/Pkgfile">pkgfile</a>  to create a database with all the packages&#8217; information. The man page advises us to have the following in a <a href="https://wiki.archlinux.org/index.php/Cron">cron</a> job:<br />
<tt># pkgfile -u</tt></p>
<p>Now look for the file (search is the default action):<br />
<tt>$ pkgfile  libwx_gtk2u_adv-2.8.so.0<br />
extra/wxgtk2.8<br />
multilib/lib32-wxgtk2.8</tt></p>
<p>There are two packages that provide such a file, the native 64 bit version and the package for the 32 bit compatibility layer. I just installed the 64 bit version because I only install software on a need basis:<br />
<tt># pacman -S wxgtk2.8</tt></p>
<p>I searched in the bug tracker and I found it has been reported several times as a bug (<a href="https://bugs.archlinux.org/task/26225">26225</a>, <a href="https://bugs.archlinux.org/task/31584">31584</a>) however the 7zip maintainer has a different stand, he explains that <tt>'wxgtk2.8'</tt> is listed as an optional dependency for the GUI and therefore you should install it if you&#8217;d like to have the graphical interface.  I disagree, if 7zip  cannot be started in KDE out of the box, then it should not install the KDE launch menu entry neither the Dolphin&#8217;s context menus, of course I also admit that I should have paid more attention to the 7zip&#8217;s optional dependency field when I installed it in the first place. </p>
<p>For the duplicate Dolphin entries the troubleshooter was Mr. Google and the credit for the fix goes to <a href="http://unix.stackexchange.com/questions/28933/7zip-context-menu-appears-twice">Juan&#8217;s answers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2013/05/29/tutti-frutti-7zip-kde-arch-linux/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">337</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>
	</item>
		<item>
		<title>FreeBSD 9.1 on VirtualBox: FAIL!!!</title>
		<link>https://thelastmaimou.wordpress.com/2013/05/24/freebsd-9-1-on-virtualbox-fail/</link>
					<comments>https://thelastmaimou.wordpress.com/2013/05/24/freebsd-9-1-on-virtualbox-fail/#comments</comments>
		
		<dc:creator><![CDATA[thepadawan42]]></dc:creator>
		<pubDate>Fri, 24 May 2013 16:57:14 +0000</pubDate>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<guid isPermaLink="false">http://thelastmaimou.wordpress.com/?p=317</guid>

					<description><![CDATA[My first attempt to try out a BSD was a failure by default: the default VirtualBox settings don&#8217;t work. I started VirtualBox, created a new machine for FreeBSD 9.1, loaded the CD ISO, run it and enjoyed an infinite reboot loop. It seemed the little demon Beastie was laughing at me, now I understand the &#8230; &#8230; <a href="https://thelastmaimou.wordpress.com/2013/05/24/freebsd-9-1-on-virtualbox-fail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>My first attempt to try out a <a href="http://en.wikipedia.org/wiki/Berkeley_Software_Distribution">BSD</a> was a failure by default: the default VirtualBox settings don&#8217;t work. I started VirtualBox, created a new machine for <a href="http://en.wikipedia.org/wiki/FreeBSD">FreeBSD</a> 9.1, loaded the CD ISO, run it and enjoyed an infinite reboot loop. It seemed the little demon <a href="http://en.wikipedia.org/wiki/Beastie_(mascot)">Beastie</a> was laughing at me, now I understand the mascot&#8230;</p>
<p><span id="more-317"></span>Fortunately, <a href="http://tomlee.co/">Tom</a> did already the investigation and found the <a href="http://tomlee.co/2012/10/installing-freebsd-9-0-on-virtualbox/">solution</a>: <b>change the system motherboard from PIIX3 to ICH9</b>. After that change the installation started but in the middle of it always aborted. I found out that it required more than the default 128 MB of RAM that VirtualBox gives for the new machine; I increased the memory to 512 MB and the installation finally was successful. Both parameters can be set in the VM settings <b>System &rarr; Motherboard</b>.</p>
<p><a href="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png"><img loading="lazy" data-attachment-id="320" data-permalink="https://thelastmaimou.wordpress.com/2013/05/24/freebsd-9-1-on-virtualbox-fail/freebsd9_virtualbox/" data-orig-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png" data-orig-size="681,527" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="freebsd9_virtualbox" data-image-description="" data-image-caption="" data-medium-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png?w=300" data-large-file="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png?w=584" src="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png?w=584" alt="freebsd9_virtualbox"   class="alignnone size-full wp-image-320" srcset="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png?w=640&amp;h=495 640w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png?w=150&amp;h=116 150w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png?w=300&amp;h=232 300w, https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png 681w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://thelastmaimou.wordpress.com/2013/05/24/freebsd-9-1-on-virtualbox-fail/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">317</post-id>
		<media:content url="https://0.gravatar.com/avatar/0995ad3cc4eb508a538c6ca90828f9e5d68a8bef1e768888103e427f0b81c7d6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thepadawan42</media:title>
		</media:content>

		<media:content url="https://thelastmaimou.wordpress.com/wp-content/uploads/2013/05/freebsd9_virtualbox.png" medium="image">
			<media:title type="html">freebsd9_virtualbox</media:title>
		</media:content>
	</item>
	</channel>
</rss>
