<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Calcifer &#187; ssh</title>
	<atom:link href="http://blog.calcifer.com.ar/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.calcifer.com.ar</link>
	<description></description>
	<lastBuildDate>Sat, 02 Oct 2010 05:32:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Chrooted SSH/SFTP Tutorial (Debian Etch)</title>
		<link>http://blog.calcifer.com.ar/2008/05/chrooted-sshsftp-tutorial-debian-etch/</link>
		<comments>http://blog.calcifer.com.ar/2008/05/chrooted-sshsftp-tutorial-debian-etch/#comments</comments>
		<pubDate>Tue, 20 May 2008 19:17:01 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2008/05/20/chrooted-sshsftp-tutorial-debian-etch/</guid>
		<description><![CDATA[Vía www.howtoforge.com
1. Install The Chrooted OpenSSH
First we install some prerequisites:
apt-get install libpam0g-dev openssl libcrypto++-dev libssl0.9.7 libssl-dev ssh build-essential bzip2
Then we download the patched OpenSSH sources, and we configure them with/usras directory for the SSH executable files, with/etc/sshas the directory where the chrooted SSH will look for configuration files, and we also allow PAM authentication:
cd /tmp
wget [...]]]></description>
			<content:encoded><![CDATA[<div class="from">Vía <a href="http://www.howtoforge.com/chroot_ssh_sftp_debian_etch" class="linkexternal">www.howtoforge.com</a></div>
<h3>1. Install The Chrooted OpenSSH</h3>
<p>First we install some prerequisites:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">apt-get</span> <span class="kw2">install</span> libpam0g-dev openssl libcrypto++-dev libssl0.9.7 libssl-dev <span class="kw2">ssh</span> build-essential <span class="kw2">bzip2</span></div></div>
<p>Then we download the patched OpenSSH sources, and we configure them with<code>/usr</code>as directory for the SSH executable files, with<code>/etc/ssh</code>as the directory where the chrooted SSH will look for configuration files, and we also allow PAM authentication:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> <span class="sy0">/</span>tmp<br />
<span class="kw2">wget</span> http:<span class="sy0">//</span>chrootssh.sourceforge.net<span class="sy0">/</span>download<span class="sy0">/</span>openssh-4.5p1-chroot.tar.bz2<br />
<span class="kw2">tar</span> xvfj openssh-4.5p1-chroot.tar.bz2<br />
<span class="kw3">cd</span> openssh-4.5p1-chroot<br />
.<span class="sy0">/</span>configure <span class="re5">--exec-prefix</span>=<span class="sy0">/</span>usr <span class="re5">--sysconfdir</span>=<span class="sy0">/</span>etc<span class="sy0">/</span><span class="kw2">ssh</span> <span class="re5">--with-pam</span><br />
<span class="kw2">make</span><br />
<span class="kw2">make</span> <span class="kw2">install</span></div></div>
<h3>2. Create The Chroot Environment</h3>
<p>Next I create a chroot environment under<code>/home/chroot</code>. This is the directory that all chrooted SSH users will get jailed in, i.e. they will not be able to see any files/directories outside<code>/home/chroot</code>.</p>
<p>I have to create some directories in<code>/home/chroot</code>, and I have to copy a few binaries like<code>/bin/bash</code>,<code>/bin/ls</code>, etc. as well as the libraries on which these binaries depend into the chroot environment so that they are available to any chrooted user.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">mkdir</span> <span class="re5">-p</span> <span class="sy0">/</span>home<span class="sy0">/</span><span class="kw2">chroot</span><span class="sy0">/</span>home<span class="sy0">/</span><br />
<span class="kw3">cd</span> <span class="sy0">/</span>home<span class="sy0">/</span><span class="kw2">chroot</span><br />
<span class="kw2">mkdir</span> <span class="re5">-p</span> usr<span class="sy0">/</span>lib<span class="sy0">/</span>openssh<br />
<span class="kw2">mkdir</span> etc<br />
<span class="kw2">mkdir</span> etc<span class="sy0">/</span>pam.d<span class="sy0">/</span><br />
<span class="kw2">mkdir</span> bin<br />
<span class="kw2">mkdir</span> lib<br />
<span class="kw2">mkdir</span> usr<span class="sy0">/</span>bin<br />
<span class="kw2">mkdir</span> dev<br />
<span class="kw2">mknod</span> dev<span class="sy0">/</span>null c <span class="nu0">1</span> <span class="nu0">3</span><br />
<span class="kw2">mknod</span> dev<span class="sy0">/</span>zero c <span class="nu0">1</span> <span class="nu0">5</span><br />
<br />
<span class="kw2">chmod</span> <span class="nu0">666</span> dev<span class="sy0">/</span>null<br />
<span class="kw2">chmod</span> <span class="nu0">666</span> dev<span class="sy0">/</span>zero</div></div>
<p>Now that we have created the necessary directories, we are going to copy some binaries and all the libraries on which they depend into the chroot environment. This is an excerpt of a script that I found on <a href="http://mail.incredimail.com/howto/openssh/create_chroot_env" class="linkexternal">http://mail.incredimail.com/howto/openssh/create_chroot_env</a> that does this. I&#8217;ve modified it a little bit:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">vi</span> <span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>sbin<span class="sy0">/</span>create_chroot_env</div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin/bash</span><br />
<span class="re2">PATH</span>=<span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>sbin:<span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>bin:<span class="sy0">/</span>usr<span class="sy0">/</span>sbin:<span class="sy0">/</span>usr<span class="sy0">/</span>bin:<span class="sy0">/</span>sbin:<span class="sy0">/</span>bin<br />
<br />
<span class="re2">APPS</span>=<span class="st0">&quot;/bin/sh /bin/bash /bin/cp /bin/ls /bin/mkdir /bin/mv /bin/pwd /bin/rm /bin/rmdir /usr/bin/id /usr/bin/ssh /usr/bin/scp /bin/ping /usr/bin/dircolors /usr/bin/vi /usr/bin/sftp /usr/lib/openssh/sftp-server&quot;</span><br />
<span class="kw1">for</span> prog <span class="kw1">in</span> <span class="re1">$APPS</span>; &nbsp;<span class="kw1">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">mkdir</span> <span class="re5">-p</span> .<span class="sy0">/`</span><span class="kw2">dirname</span> <span class="re1">$prog</span><span class="sy0">`</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;&amp;</span><span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">cp</span> <span class="re1">$prog</span> .<span class="sy0">/</span><span class="re1">$prog</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co0"># obtain a list of related libraries</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">ldd</span> <span class="re1">$prog</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;$?&quot;</span> = <span class="nu0">0</span> <span class="br0">&#93;</span> ; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">LIBS</span>=<span class="sy0">`</span><span class="kw2">ldd</span> <span class="re1">$prog</span> <span class="sy0">|</span> <span class="kw2">awk</span> <span class="st_h">'{ print $3 }'</span><span class="sy0">`</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> l <span class="kw1">in</span> <span class="re1">$LIBS</span>; <span class="kw1">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">mkdir</span> <span class="re5">-p</span> .<span class="sy0">/`</span><span class="kw2">dirname</span> <span class="re1">$l</span><span class="sy0">`</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;&amp;</span><span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">cp</span> <span class="re1">$l</span> .<span class="sy0">/</span><span class="re1">$l</span> &nbsp;<span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;&amp;</span><span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">done</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">fi</span><br />
<span class="kw1">done</span></div></div>
<p>(If you want to make more programs available to your chrooted users, just add these programs to the APPS line.)</p>
<p>Now we make the script executable and run it:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">chmod</span> <span class="nu0">700</span> <span class="sy0">/</span>usr<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>sbin<span class="sy0">/</span>create_chroot_env<br />
create_chroot_env</div></div>
<p>Next we have to copy a few additional files and libraries to the chroot jail:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">cp</span> <span class="sy0">/</span>lib<span class="sy0">/</span>libnss_compat.so.2 <span class="sy0">/</span>lib<span class="sy0">/</span>libnsl.so.1 <span class="sy0">/</span>lib<span class="sy0">/</span>libnss_files.so.2 <span class="sy0">/</span>lib<span class="sy0">/</span>ld-linux.so.2 <span class="sy0">/</span>lib<span class="sy0">/</span>libcap.so.1 <span class="sy0">/</span>lib<span class="sy0">/</span>libnss_dns.so.2 .<span class="sy0">/</span>lib<span class="sy0">/</span><br />
<br />
<span class="kw2">cp</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts etc<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>etc<span class="sy0">/</span>resolv.conf etc<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>etc<span class="sy0">/</span>pam.d<span class="sy0">/*</span> etc<span class="sy0">/</span>pam.d<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="re5">-r</span> <span class="sy0">/</span>lib<span class="sy0">/</span>security lib<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="re5">-r</span> <span class="sy0">/</span>etc<span class="sy0">/</span>security etc<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>etc<span class="sy0">/</span>login.defs etc<span class="sy0">/</span><br />
<br />
<span class="kw2">cp</span> <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>libgssapi_krb5.so.2 usr<span class="sy0">/</span>lib<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>libkrb5.so.3 usr<span class="sy0">/</span>lib<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>libk5crypto.so.3 usr<span class="sy0">/</span>lib<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>lib<span class="sy0">/</span>libcom_err.so.2 lib<span class="sy0">/</span><br />
<span class="kw2">cp</span> <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>libkrb5support.so.0 usr<span class="sy0">/</span>lib<span class="sy0">/</span></div></div>
<p>Then we do this:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">echo</span> <span class="st_h">'#!/bin/bash'</span> <span class="sy0">&gt;</span> usr<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">groups</span><br />
<span class="kw3">echo</span> <span class="st0">&quot;id -Gn&quot;</span> <span class="sy0">&gt;&gt;</span> usr<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">groups</span><br />
<span class="kw2">touch</span> etc<span class="sy0">/</span><span class="kw2">passwd</span><br />
<span class="kw2">grep</span> <span class="sy0">/</span>etc<span class="sy0">/</span><span class="kw2">passwd</span> <span class="re5">-e</span> <span class="st0">&quot;^root&quot;</span> <span class="sy0">&gt;</span> etc<span class="sy0">/</span><span class="kw2">passwd</span></div></div>
<p>You should also copy the line of the group in which you will create new users from<code>/etc/group</code>to<code>/home/chroot/etc/group</code>. In this tutorial we will create users in the group users, so we do this:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">grep</span> <span class="sy0">/</span>etc<span class="sy0">/</span>group <span class="re5">-e</span> <span class="st0">&quot;^root&quot;</span> <span class="re5">-e</span> <span class="st0">&quot;^users&quot;</span> <span class="sy0">&gt;</span> etc<span class="sy0">/</span>group</div></div>
<p>and restart OpenSSH:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">/</span>etc<span class="sy0">/</span>init.d<span class="sy0">/</span><span class="kw2">ssh</span> restart</div></div>
<h3>3. Create A Chrooted User</h3>
<p>Even with the chrooted SSH that we have just installed you can log in without being chrooted (which makes sense if you log in as root, for example). Now, how does the chrooted SSH decide whom to chroot and whom not? That&#8217;s easy: the chrooted SSH looks up the user who is trying to log in in<code>/etc/passwd</code>. If the user&#8217;s home directory in<code>/etc/passwd</code>has a . (dot) in it, then the user is going to be chrooted.</p>
<p>This user will not be chrooted.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">user_a:x:<span class="nu0">2002</span>:<span class="nu0">100</span>:User A:<span class="sy0">/</span>home<span class="sy0">/</span>user_a:<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">bash</span></div></div>
<p>This user will be chrooted.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">user_b:x:<span class="nu0">2003</span>:<span class="nu0">100</span>:User B:<span class="sy0">/</span>home<span class="sy0">/</span><span class="kw2">chroot</span><span class="sy0">/</span>.<span class="sy0">/</span>home<span class="sy0">/</span>user_b:<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">bash</span></div></div>
<p>Now we create the user testuser with the home directory<code>/home/chroot/./home/testuser</code>and the group users (which is the default group for users on Debian so you do not have to specify it explicitly):</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">useradd <span class="re5">-s</span> <span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">bash</span> <span class="re5">-m</span> <span class="re5">-d</span> <span class="sy0">/</span>home<span class="sy0">/</span><span class="kw2">chroot</span><span class="sy0">/</span>.<span class="sy0">/</span>home<span class="sy0">/</span>testuser <span class="re5">-c</span> <span class="st0">&quot;testuser&quot;</span> <span class="re5">-g</span> <span class="kw2">users</span> testuser</div></div>
<p>Then we give testuser a password:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">passwd</span> testuser</div></div>
<p>Finally, we have to copy the line for testuser in<code>/etc/passwd</code>to<code>/home/chroot/etc/passwd</code>:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">grep</span> <span class="sy0">/</span>etc<span class="sy0">/</span><span class="kw2">passwd</span> <span class="re5">-e</span> <span class="st0">&quot;^testuser&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>home<span class="sy0">/</span><span class="kw2">chroot</span><span class="sy0">/</span>etc<span class="sy0">/</span><span class="kw2">passwd</span></div></div>
<p>We have already copied the users group line from<code>/etc/group</code>to<code>/home/chroot/etc/group</code>so we do not have to do this here again. If you create a chrooted user in another group than users, add this group to<code>/home/chroot/etc/group</code>:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">grep</span> <span class="sy0">/</span>etc<span class="sy0">/</span>group <span class="re5">-e</span> <span class="st0">&quot;^othergroup&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>home<span class="sy0">/</span><span class="kw2">chroot</span><span class="sy0">/</span>etc<span class="sy0">/</span>group</div></div>
<p>Now try to log in to SSH or SFTP as testuser. You should be chrooted and not be able to browse files/directories outside<code>/home/chroot</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2008/05/chrooted-sshsftp-tutorial-debian-etch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Montar un directorio remoto usando SSHFS</title>
		<link>http://blog.calcifer.com.ar/2007/07/montar-un-directorio-remoto-usando-sshfs/</link>
		<comments>http://blog.calcifer.com.ar/2007/07/montar-un-directorio-remoto-usando-sshfs/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 13:32:40 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2007/07/27/montar-un-directorio-remoto-usando-sshfs/</guid>
		<description><![CDATA[Instalar sshfs
sudo apt-get install sshfs
Cargar el módulo fuse (lsmod &#124; grep fuse)
sudo modprobe fuse
Agregar el usuario user al grupo fuse y cambiar el grupo a/dev/fuse
sudo chgrp /dev/fuse fuse
Finalmente, montar el directorio remoto
sshfs user@remote_server:/remote_folder ~/local_folder
Para desmontar
fusermount -u ~/local_folder
]]></description>
			<content:encoded><![CDATA[<p>Instalar sshfs</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">sudo</span> <span class="kw2">apt-get</span> <span class="kw2">install</span> sshfs</div></div>
<p>Cargar el módulo fuse (<code>lsmod | grep fuse</code>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">sudo</span> modprobe fuse</div></div>
<p>Agregar el usuario user al grupo fuse y cambiar el grupo a<code>/dev/fuse</code></p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">sudo</span> <span class="kw2">chgrp</span> <span class="sy0">/</span>dev<span class="sy0">/</span>fuse fuse</div></div>
<p>Finalmente, montar el directorio remoto</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">sshfs user<span class="sy0">@</span>remote_server:<span class="sy0">/</span>remote_folder ~<span class="sy0">/</span>local_folder</div></div>
<p>Para desmontar</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">fusermount <span class="re5">-u</span> ~<span class="sy0">/</span>local_folder</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2007/07/montar-un-directorio-remoto-usando-sshfs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web server desde una red interna usando SSH</title>
		<link>http://blog.calcifer.com.ar/2006/07/web-server-desde-una-red-interna-usando-ssh/</link>
		<comments>http://blog.calcifer.com.ar/2006/07/web-server-desde-una-red-interna-usando-ssh/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 13:55:10 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[networks]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2006/07/20/web-server-desde-una-red-interna-usando-ssh/</guid>
		<description><![CDATA[Supongamos que tenemos una máquina dentro de una red interna ejecutando un servidor web y queremos que dicho servidor pueda ser accedido desde el exterior. Supongamos también que tenemos una cuenta SSH en el gateway que nos da salida a Internet&#8230; aunque, lamentablemente, no somos su administrador.
La idea es abrir un puerto en el gateway [...]]]></description>
			<content:encoded><![CDATA[<p>Supongamos que tenemos una máquina dentro de una red interna ejecutando un servidor web y queremos que dicho servidor pueda ser accedido desde el exterior. Supongamos también que tenemos una cuenta SSH en el gateway que nos da salida a Internet&#8230; aunque, lamentablemente, no somos su administrador.</p>
<p>La idea es abrir un puerto en el gateway (por encima del 1023) y redireccionar todas las conexiones entrantes al puerto 80 de nuestra máquina interna, que es donde está escuchando nuestro servidor web. Para ello crearemos un túnel SSH entre el gateway y nuestra máquina:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ssh &nbsp;-g -L 10080:localhost:80 usuario@maq_interna -N</div></div>
<p>Este comando debemos ejecutarlo desde el gateway, ya que estamos usando la opción<code>-L</code>(local).</p>
<p>La opción -g (que equivale a &#8216;GatewayPorts yes&#8217; en<code>~/.ssh/config</code>o<code>/etc/ssh/ssh_config</code>) es muy importante, ya que sin ella el túnel sólo estaría disponible para conexiones desde localhost y nosotros queremos que cualquier persona en Internet pueda acceder a nuestro servidor web.</p>
<p>Para comprobar esto basta con ejecutar:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">netstat -nlpt</div></div>
<p>Deberíamos ver una línea como la siguiente:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">tcp6 &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp;0 : : :10080 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : : : * &nbsp; &nbsp; &nbsp;LISTEN &nbsp; &nbsp; 12414/ssh</div></div>
<p>Lo que nos  indica que el puerto 10080 está escuchando conexiones provenientes desde cualquier dirección y no sólo desde 127.0.0.1.</p>
<p>Por último, la opción<code>-N</code>le indica a SSH que luego de crear el túnel no nos devuelva el prompt del shell.</p>
<p>Listo. Sólo basta abrir un navegador e ingresar:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">http://ip_gateway:10080</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2006/07/web-server-desde-una-red-interna-usando-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Port Forwarding Through a Proxy Server</title>
		<link>http://blog.calcifer.com.ar/2006/07/ssh-port-forwarding-through-a-proxy-server/</link>
		<comments>http://blog.calcifer.com.ar/2006/07/ssh-port-forwarding-through-a-proxy-server/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 12:18:25 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2006/07/20/ssh-port-forwarding-through-a-proxy-server/</guid>
		<description><![CDATA[By Terry Labach, January, 2005
A common use of SSH is port forwarding (tunneling). This use causes traffic directed to a particular port to be sent to a specified port on another computer. Because traffic is sent through SSH, the traffic is encrypted, allowing the transmission of sensitive data through arbitrary services.
Example: Tunneling Connections From a [...]]]></description>
			<content:encoded><![CDATA[<p class="from">By Terry Labach, January, 2005</p>
<p>A common use of SSH is port forwarding (tunneling). This use causes traffic directed to a particular port to be sent to a specified port on another computer. Because traffic is sent through SSH, the traffic is encrypted, allowing the transmission of sensitive data through arbitrary services.</p>
<p>Example: Tunneling Connections From a Local Host on Port 8080 to Port 80 on a Web Server</p>
<p>The following command is an example that would tunnel connections from a local host on port 8080 to port 80 on the web server www.my-domain.com:</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ssh -N -L 8080:localhost:80 www.my-domain.com</div></div>
</pre>
<p>In the preceding command:</p>
<p>    * The</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">-N</div></div>
<p>switch prevents the creation of an interactive SSH session.<br />
    * The</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">-L</div></div>
<p>switch accepts an argument of the form port:host:hostport, indicating that the local port is to be forwarded to hostport on the destination host. Therefore, the argument localhost is relative to www.my-domain.com, not to the machine at which you enter the command.</p>
<h4>Example: Accessing a Corporate Network Web Server That Allows Logins Through a Proxy Server</h4>
<p>It follows that one could create a sequence of secure tunnels, linking one computer to another through intermediate computers. The most likely use for this scenario would be to enter a private network that requires external logins to be performed through a proxy server.</p>
<p>Suppose you wanted to access a web server in a corporate network that allowed logins through a proxy server. This could be done in two steps:</p>
<p>1. Log in to the proxy server using SSH, while simultaneously creating a tunnel. Use the following command:</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ssh -l proxyuser -L 8080:localhost:8181 proxy.my-domain.com</div></div>
</pre>
<p>This command logs the user proxyuser into proxy.my-domain.com, as well as forwards access to localhost&#8217;s port 8080 to 8181 on the proxy server. (Note that the port on the proxy server should not interfere with other users&#8217; tunnels. The administrator of the proxy server should assign ports to users that can be used in this manner.)</p>
<p>2. Once logged in, create a second tunnel from the proxy server to the internal server:</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ssh -l internaluser -L 8181:internalserver:80 internalserver</div></div>
</pre>
<p>However, SSH can be used to run arbitrary commands on a remote machine. This capability allows you to create the tunnel in one step, with a single command line:</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ssh -t -l proxyuser -L 8080:localhost:8181 proxy.my-domain.com \<br />
ssh -l internaluser -L 8181:internalserver:80 internalserver</div></div>
</pre>
<p>The</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">-t</div></div>
<p>switch forces pseudo-tty allocation, which is necessary to run the SSH instance on the proxy server.</p>
<p>After you run the command, a user has a login session on the internal machine, and local port 8080 is forwarded to port 80 on the internal machine. When the user logs out of the internal machine, the port forwarding stops.</p>
<h4>A Practical Application: Allowing Remote Access to the Perforce Master Source Repository</h4>
<p>An example of a practical application of this technique comes from a solution I created for a client. Software developers using the Perforce source-code management system wanted remote access to the master source repository. Their corporate firewall software did not support Linux-based VPNs. For those developers using laptops or developers whose ISPs did not provide static IP addresses, access could not be provided through the firewall based on IPs.</p>
<p>To allow remote use of Perforce under these restrictions, I decided to tunnel the connections.</p>
<p>To create a tunnel for Perforce through SSH, clients run the following command, entering pass phrases or passwords as prompted:</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">ssh -P -t -l proxyuser -L 1616:localhost:2468 proxy.my-domain.com \<br />
ssh -l internaluser -L 2468:internalserver:1616 internalserver</div></div>
</pre>
<p>The</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">-P</div></div>
<p>switch causes SSH to use a non-privileged port for outgoing connections, which may be required for some firewalls, as it was for this client. In the command above, 1616 is the standard Perforce port, and 2468 is an arbitrarily selected port, allocated for a particular user on the proxy server. (Each user had two unprivileged ports assigned for the user&#8217;s own use.) By having the local port set to 1616, Perforce clients worked with no configuration changes, as though a Perforce server were running locally.</p>
<h4>Conclusion</h4>
<p>SSH tunneling through a proxy server can be done quickly and simply using a single command line, providing transparent, secure access to network services.</p>
<h4>Note</h4>
<p>sshd must allow port forwarding for this technique to work. If this capability is not allowed by default, the parameter AllowTcpForwarding must be set to yes in the sshd configuration file.</p>
<h4>About the Author</h4>
<p>Terry Labach has been a system administrator since the last century, supporting the Solaris OS and other versions of UNIX. He holds university degrees in Physics and Computer Science.</p>
<p><a href="http://www.sun.com/bigadmin/content/submitted/ssh_port_fwd.html" class="linkexternal">http://www.sun.com/bigadmin/content/submitted/ssh_port_fwd.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2006/07/ssh-port-forwarding-through-a-proxy-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

