<?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>AB-WebLog.com&#187; rbash</title>
	<atom:link href="http://www.ab-weblog.com/en/tag/rbash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ab-weblog.com/en</link>
	<description>Andreas Breitschopp</description>
	<lastBuildDate>Wed, 18 Mar 2015 09:47:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a Restricted SSH User for SSH Tunneling Only</title>
		<link>http://www.ab-weblog.com/en/creating-a-restricted-ssh-user-for-ssh-tunneling-only/</link>
		<comments>http://www.ab-weblog.com/en/creating-a-restricted-ssh-user-for-ssh-tunneling-only/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 14:54:58 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PATH]]></category>
		<category><![CDATA[rbash]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[tunneling]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=453</guid>
		<description><![CDATA[Sometimes it is necessary to use SSH tunneling to access a web service on a specific port that is blocked by a firewall or router. Of course, you could create just a new SSH user on your Linux server, but &#8230; <a href="http://www.ab-weblog.com/en/creating-a-restricted-ssh-user-for-ssh-tunneling-only/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is necessary to use SSH tunneling to access a web service on a specific port that is blocked by a firewall or router.</p>
<p>Of course, you could create just a new SSH user on your Linux server, but this user will be able to execute all server commands although they would not be necessary for SSH tunneling. In fact the only thing the user needs is to login and logout again – that&#8217;s enough! Therefore we don&#8217;t want the user to be able to do anything else for security reasons.</p>
<p>I will show in the following how you can create such a restricted SSH user on a Linux server (tested on Debian Linux) that can be used for SSH tunneling only.</p>
<p>First of all we create a new user (I just call him <code class="brush: bash; gutter: false">sshtunnel</code> now) with <code class="brush: bash; gutter: false">rbash</code> as shell:</p>
<pre class="brush: bash; gutter: true">useradd sshtunnel -m -d /home/sshtunnel -s /bin/rbash
passwd sshtunnel</pre>
<p>Using <code class="brush: bash; gutter: false">rbash</code> instead of <code class="brush: bash; gutter: false">bash</code> will restrict the user already as he especially cannot change the directory and cannot set any environment variables. But the user can still execute most of the bash commands.</p>
<p>To prevent him from this, we use a small trick: we set the environment variable <code class="brush: bash; gutter: false">PATH</code> for this user to nothing. This way the bash won&#8217;t find the commands to execute anymore. That&#8217;s easily done by adding this line to the end of the file <code class="brush: bash; gutter: false">.profile</code> in the home directory of the user (in our example it is <code class="brush: bash; gutter: false">/home/sshtunnel/</code>):</p>
<pre class="brush: bash; gutter: false">PATH=&quot;&quot;</pre>
<p>As we want to make sure the user is not able to change this again himself, we remove the write permissions from the user configuration files and from the home directory of the user itself:</p>
<pre class="brush: bash; gutter: true">chmod 555 /home/sshtunnel/
cd /home/sshtunnel/
chmod 444 .bash_logout .bashrc .profile</pre>
<p>Now we&#8217;re done: you can setup your SSH tunnel for example with PuTTY just as normal and login with this newly created SSH user. You won&#8217;t be able to do anything else than login and logout anymore, but SSH tunneling will work fine!</p>
<p><em>Did you also need such a restricted SSH user already?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/creating-a-restricted-ssh-user-for-ssh-tunneling-only/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->