<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=89.28.3.241</id>
		<title>FreeBSDwiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=89.28.3.241"/>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/Special:Contributions/89.28.3.241"/>
		<updated>2026-09-24T05:23:47Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://freebsdwiki.net/index.php/Category:Architecture-Specific</id>
		<title>Category:Architecture-Specific</title>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/Category:Architecture-Specific"/>
				<updated>2007-11-16T15:05:55Z</updated>
		
		<summary type="html">&lt;p&gt;89.28.3.241: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This category contains articles specific to the care and feeding of particular platform architectures (Sparc, AMD64, ia64, PPC, etc) under FreeBSD.  Articles in this category should begin with the architecture name to aid sorting - for instance &amp;quot;Installing FreeBSD on Sparc&amp;quot; [http://www.cigland.com/ .]should instead be named [[Sparc - Installing FreeBSD]].&lt;br /&gt;
&lt;br /&gt;
If you would like to add your article to this category, simply add the tag '''&amp;lt;nowiki&amp;gt;[[Category : Architecture-Specific]]&amp;lt;/nowiki&amp;gt;''' to the bottom of your article.&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>89.28.3.241</name></author>	</entry>

	<entry>
		<id>http://freebsdwiki.net/index.php/SSH,_limiting_to_SCP_or_Rsync_only</id>
		<title>SSH, limiting to SCP or Rsync only</title>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/SSH,_limiting_to_SCP_or_Rsync_only"/>
				<updated>2007-11-16T14:56:44Z</updated>
		
		<summary type="html">&lt;p&gt;89.28.3.241: /* scpsftprsynconly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Fairly commonly, you may want to set something up so that a user can [[scp]] or [[rsync]] files to (or from) a server of yours, but you don't want to allow them a shell account.  That's not ENTIRELY possible, but you can manage something along those lines by either creating a [[jail]] for them, or, more simply, by forcing them to use a very very neutered custom [[shell]] when they log in that will only allow them access to the commands that you want them to be able to use.&lt;br /&gt;
&lt;br /&gt;
The general idea is to create a [[custom shell]] for user accounts that you want to be able to use [[scp]], [[sftp]], or [[rsync]] with SSH transport, but not to have an actual shell available.  Remember that this limits &amp;quot;snoopiness&amp;quot; to some degree but is NOT any kind of hardcore lockout, as any files or directories that the user has read permissions on can be [[scp]]'ed or [[rsync]]'ed over to their machine for local perusal, and any which they have write permissions on can be OVERWRITTEN with versions [[scp]]'ed or [[rsync]]'ed over FROM their machine!&lt;br /&gt;
&lt;br /&gt;
Note also that scpsftprsynconly, as written, wouldn't prevent a belligerent user from using the -S argument to [[scp]] to execute an arbitrary script or program instead of ssh.  An enterprising soul could of course modify the code to prevent the use of a -S argument; the main reason I haven't bothered is, well, you're kidding yourself if you think either of these are ''secure'' ideas anyway - they're popular, and they'll keep clueless lusers in line, but they won't deter determined and knowledgeable types for long.  (I don't know off the top of my head if the '''scponly''' shell is also vulnerable to this particular exploit - if somebody wants to go over its source and report back here, that would be nice.)&lt;br /&gt;
&lt;br /&gt;
==scponly==&lt;br /&gt;
&lt;br /&gt;
[http://www.sublimation.org/scponly/ scponly] is open-source software that offers this functionality. It is available through the ports collection under /usr/ports/shells/scponly.&lt;br /&gt;
&lt;br /&gt;
==scpsftprsynconly==&lt;br /&gt;
&lt;br /&gt;
An alternative is to use the small C program at the bottom of this article. Once you've saved the code to a work directory as '''scpsftprsynconly.c''', you can compile it and assign it as a user's shell with [[pw]] or [[chsh]]:&lt;br /&gt;
&lt;br /&gt;
 ph34r# '''gcc scpsftprsynconly.c -o /usr/local/bin/scpsftprsynconly'''&lt;br /&gt;
 ph34r# '''pw usermod dave -s /usr/local/bin/scpsftprsynconly'''&lt;br /&gt;
&lt;br /&gt;
Now user '''dave''' can use scp or sftp (if sftp is set up) or rsync (if rsync is available) commands with ssh, but cannot actually log into the box - remotely OR locally I might add!  Here's a test showing ssh and local logins failing, but an scp succeeding:&lt;br /&gt;
&lt;br /&gt;
 ph34r# '''ssh dave@localhost'''&lt;br /&gt;
 This account is currently not available.&lt;br /&gt;
 ph34r# '''su dave'''&lt;br /&gt;
 This account is currently not available.&lt;br /&gt;
 ph34r# '''scp dave@localhost:/usr/local/bin/scpsftprsynconly .&lt;br /&gt;
 Password:&lt;br /&gt;
 scpsftprsynconly                               100%  130KB 129.7KB/s   00:00&lt;br /&gt;
&lt;br /&gt;
And there we have it - it works.  Note that you might want to actually LOOK at the code; it's assuming that rsync and scp will be findable via the system's PATH environment variable.  If that's not the case, or if you're feeling a little extra-paranoid and want to hard-code in assurance [http://www.cigland.com/ .] that ONLY the particular executable you want - say, '''/usr/local/bin/rsync''' - can be run, you might want to hack that in the way you want it; just keep in mind that if your custom shell is looking to allow just '''rsync''', it WON'T allow '''/usr/local/bin/rsync''' and vice versa.  So you might wind up having to mess about with flags for your scp and rsync commands from remote machines to specify paths, if you screw around with that stuff.&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;string.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
 **  Original by Patric Draper &amp;lt;http://www.pdrap.org/about/&amp;gt;&lt;br /&gt;
 **&lt;br /&gt;
 **  Changes on 13-Mar-2004 by Msquared &amp;lt;http://www.msquared.id.au/&amp;gt;&lt;br /&gt;
 **&lt;br /&gt;
 **    * fixed bug in args to realloc()&lt;br /&gt;
 **    * fixed bug in parameter checks (validates entire command name)&lt;br /&gt;
 **    * Modified to work with OpenSSH SFTP&lt;br /&gt;
 **    * Added rsync support&lt;br /&gt;
 **&lt;br /&gt;
 **  This code is in the public domain.  No warranty.  If it breaks,&lt;br /&gt;
 **  you can dispose of it as you see fit.&lt;br /&gt;
 **&lt;br /&gt;
 **  Build with DEBUG to save calling arguments to /tmp/scpshell.log&lt;br /&gt;
 **  This is useful to add new protocols, debug existing calls, etc.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
 char * restrictmsg = &amp;quot;This account is currently not available.\n&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 int main (int argc, char *argv []) {&lt;br /&gt;
         char **newargs = NULL;&lt;br /&gt;
         char *newbuff = NULL;&lt;br /&gt;
         int i;&lt;br /&gt;
         char *s;&lt;br /&gt;
 &lt;br /&gt;
 #ifdef DEBUG&lt;br /&gt;
 &lt;br /&gt;
         FILE * log = fopen(&amp;quot;/tmp/scpshell.log&amp;quot;,&amp;quot;a+&amp;quot;);&lt;br /&gt;
         if ( log ) {&lt;br /&gt;
                 char **par = argv;&lt;br /&gt;
                 while ( *par )&lt;br /&gt;
                         fprintf ( log, &amp;quot;[%s] &amp;quot;, *par++ );&lt;br /&gt;
                 fprintf ( log, &amp;quot;\n&amp;quot; );&lt;br /&gt;
                 fclose(log);&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
 #endif&lt;br /&gt;
 &lt;br /&gt;
         if (argc &amp;lt; 3) {&lt;br /&gt;
                 printf (restrictmsg);&lt;br /&gt;
                 return 1;&lt;br /&gt;
         }&lt;br /&gt;
         if ((strncmp (argv [2], &amp;quot;scp &amp;quot;, 4) != 0) &amp;amp;&amp;amp;&lt;br /&gt;
             (strncmp (argv [2], &amp;quot;/usr/libexec/openssh/sftp-server&amp;quot;, 33) != 0) &amp;amp;&amp;amp;&lt;br /&gt;
             (strncmp (argv [2], &amp;quot;rsync &amp;quot;, 6) != 0)) {&lt;br /&gt;
                 printf (restrictmsg);&lt;br /&gt;
                 return 2;&lt;br /&gt;
         }&lt;br /&gt;
         i = 0;&lt;br /&gt;
         newbuff = strdup(argv[2]);&lt;br /&gt;
         s = strtok (newbuff, &amp;quot; &amp;quot;);&lt;br /&gt;
         do {&lt;br /&gt;
                 newargs = (char **) realloc (newargs, ++i*sizeof(*newargs));&lt;br /&gt;
                 newargs [i - 1] = strdup (s);&lt;br /&gt;
         } while ((s = strtok (NULL, &amp;quot; &amp;quot;)) != NULL);&lt;br /&gt;
 &lt;br /&gt;
         newargs = (char **) realloc (newargs, ++i*sizeof(*newargs));&lt;br /&gt;
         newargs [i - 1] = NULL;&lt;br /&gt;
 &lt;br /&gt;
         execvp (newargs [0], newargs);&lt;br /&gt;
 &lt;br /&gt;
         return 0;&lt;br /&gt;
 }&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Common Tasks]] [[Category:FreeBSD for Servers]][[Category:Securing FreeBSD]]&lt;/div&gt;</summary>
		<author><name>89.28.3.241</name></author>	</entry>

	</feed>