<?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>Shekhar Govindarajan's Blog &#187; denied</title>
	<atom:link href="http://www.shekhargovindarajan.com/tag/denied/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shekhargovindarajan.com</link>
	<description>My Notepad on the Web</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:58:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com/" />
			<item>
		<title>Secure File Transfer without Secure Shell</title>
		<link>http://www.shekhargovindarajan.com/tips-n-tricks/secure-file-transfer-without-secure-shell/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=secure-file-transfer-without-secure-shell</link>
		<comments>http://www.shekhargovindarajan.com/tips-n-tricks/secure-file-transfer-without-secure-shell/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 12:20:34 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Tips N Tricks]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[barred]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[denied]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[scponly]]></category>
		<category><![CDATA[Secure Shell]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[text editor]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=625</guid>
		<description><![CDATA[FTP (File Transfer Protocol) is the de-facto but unsecure method to transfer files. SSH (Secure Shell) and its family of services like SCP (Secure Copy) and SFTP (Secure FTP) allows you shell (telnet like) access as well as file transfer via SCP and SFTP, securely. By &#8220;securely&#8221; I mean the data is that flows across [...]]]></description>
			<content:encoded><![CDATA[<p>FTP (File Transfer Protocol) is the de-facto but unsecure method to transfer files. SSH (Secure Shell) and its family of services like SCP (Secure Copy) and SFTP (Secure FTP) allows you shell (telnet like) access as well as file transfer via SCP and SFTP, securely. By &#8220;securely&#8221; I mean the data is that flows across is encrypted including the username and password. SSH is a popular protocol for shell access and file transfer in the Linux world.</p>
<p>So given a choice, SCP/SFTP is a better option in terms of &#8220;security&#8221;. But enabling SFTP/SCP enables, by default, shell access too. Recently for one of my clients, the requirement was to use SCP instead of FTP while blocking shell access so that no user is able to login, in curiosity, nor could execute any program/script on the server, even by mistake. All they could do is to copy files across &#8211; from their desktop to the server and vice versa.  But, I could not find anything in  SSH configuration that barred SSH, while still allowing SCP.<span id="more-625"></span></p>
<p>The solution lied outside SSH and was trivial. It is called <strong>scponly</strong>. scponly is a shell program, just like Bash, Ksh which barrs shell access via SSH. I had <a href="http://www.centos.org/" target="_blank">CentOS</a> 5.2 running on the client&#8217;s server. scponly RPM was not available from the CentOS repositories. I then setup the <a href="https://rpmrepo.org/RPMforge/Using" target="_blank">RPMForge repository</a> as follows:</p>
<p><em> rpm -ivh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm</em></p>
<p>Note that the above setup is specific to CentOS 5. Subsequently, I installed scponly as:</p>
<p><em>yum install scponly</em></p>
<p>Next, the shell of all the users, who are barred SSH access, must be set to /usr/bin/scponly. For existing users there are two ways to do it:</p>
<p><strong>Method 1: Using usermod (Recommended)<br />
</strong>Login as root and issue the following command:</p>
<p><em>usermod &#8211;shell /usr/bin/scponly &lt;username&gt;</em></p>
<p>Substitue &lt;username&gt; with the name of the user who will be barred shell access</p>
<p><strong>Method 2: Edit /etc/passwd<br />
</strong>Login as root and open the file named passwd, found in /etc directory, in a text editor. The file contains entry for each user on a seperate line along with their shell name. For example:</p>
<p><em>&lt;username&gt;:x:506:508::/home/&lt;username&gt;:/bin/bash</em></p>
<p>Replace /bin/bash with /usr/bin/scponly. Save the file. This will change the shell of the user named &lt;username&gt; to scponly.</p>
<p><strong>For new users<br />
</strong>For new users you can set the shell to scponly while creating the user via useradd command:</p>
<p><em>useradd &#8211;shell /usr/bin/scponly &lt;username&gt;</em></p>
<p>Once done, when one (who is barred the shell access) tries to SSH, he/she will be able to proceed upto the point of the password prompt. At the prompt, even after supplying a correct password, he/she will not be dropped into a shell. In fact it will appear as if the SSH login has hung &#8211; no errors, no access denied messages.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=625&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/tips-n-tricks/secure-file-transfer-without-secure-shell/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

