LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-11-2006, 01:17 PM   #1
b8rt
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Rep: Reputation: 0
cat as a login shell


Are there any security issues of setting a user's login shell to:

/usr/bin/cat

I have done this effectively to disable users from getting a shell with ssh, but still be able to do ssh port forwarding...

What can go wrong?

-b8rt
 
Old 12-11-2006, 01:37 PM   #2
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
What about /usr/bin/true ? I would think that's safer than cat because it shouldn't allow writing to arbitrary files.
 
Old 12-11-2006, 01:43 PM   #3
b8rt
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Original Poster
Rep: Reputation: 0
When I set it to /usr/bin/true the ssh connection I attempt exits right away, as is the nature of `true`. When it is `cat`, the ssh connection stays open, all port forwarding works, and all the user seems to be capable of is typing in their terminal... I don't see how they can write to files...

-b8rt
 
Old 12-11-2006, 01:55 PM   #4
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Actually, you're right cat wouldn't allow writing to files any more than true would, without output redirection. It could allow reading files though (if you're trying to prohibit logins, that could be a problem. So what you're really looking for is an infinite loop or infinite blocking.

What about compiling a simple C program to simply sleep() inside an infinite loop?
 
Old 01-20-2012, 12:00 PM   #5
b8rt
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Original Poster
Rep: Reputation: 0
A C++ app that does nothing...

Code:
$ cat idle.cpp 
#include <iostream>

int main(){
  std::cout << "Doing nothing...forever!\n" << std::flush;
  while(1){sleep(1);}
  return 0;
}

$ g++ idle.cpp -o idle
$ ./idle 
Doing nothing...forever!

Last edited by b8rt; 01-20-2012 at 03:58 PM. Reason: syntax
 
Old 01-20-2012, 03:26 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by b8rt View Post
When I set it to /usr/bin/true the ssh connection I attempt exits right away, as is the nature of `true`.
I don't have an ssh server handy to test this on, but does it still exit right away if you use the -N option on the client side?

Code:
     -N      Do not execute a remote command.  This is useful for just
             forwarding ports (protocol version 2 only).

http://www.openbsd.org/cgi-bin/man.c...=ssh&sektion=1
 
Old 01-20-2012, 03:44 PM   #7
b8rt
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Original Poster
Rep: Reputation: 0
ntubski, indeed -N for ssh just connects and executes nothing. On the other hand, changing the default shell to an idle process seems to make it mandatory for the user and not optional.

-
bart

Last edited by b8rt; 01-20-2012 at 03:45 PM. Reason: spell fix
 
Old 01-21-2012, 09:42 AM   #8
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Debian
Posts: 202

Rep: Reputation: 36
/usr/sbin/nologin was created for your purpose.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between normal shell and login shell Manish Linux - General 7 11-14-2012 08:30 AM
Shell Script Arrays - Running cat revof11 Programming 4 11-28-2006 12:36 PM
cat in asm/ cat --show-all option Tux Linux - Software 1 09-02-2006 09:31 PM
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 08:28 AM
crontabbed shell script, trying to echo/cat something zaubara Programming 2 06-13-2004 07:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration