Personal computing discussed

Moderators: renee, SecretSquirrel, notfred

 
cheesyking
Minister of Gerbil Affairs
Topic Author
Posts: 2756
Joined: Sun Jan 25, 2004 7:52 am
Location: That London (or so I'm told)
Contact:

Restricted shell, I think.

Tue Mar 20, 2007 9:10 am

I'm looking to give users on an Edgy machine restricted ssh access.

All I want them to do is login with putty so that they can tunnel a connection to an internal webserver on another machine.

I'm not too sure what the best way of doing that is. I've been doing a bit of reading on restricted shells which seem to be the kind of thing I'm looking for. This is one I stumbled across that sounds promising http://ibsh.sourceforge.net/docs.html but I'd like some advice before I dive in.

I'd really like a way of restricting some users so they can only tunnel to a specific host on the internal network but anything is better than nothing.
Fernando!
Your mother ate my dog!
 
bitvector
Grand Gerbil Poohbah
Posts: 3293
Joined: Wed Jun 22, 2005 4:39 pm
Location: San Francisco, CA

Re: Restricted shell, I think.

Tue Mar 20, 2007 12:48 pm

cheesyking wrote:
All I want them to do is login with putty so that they can tunnel a connection to an internal webserver on another machine.
...
I'd really like a way of restricting some users so they can only tunnel to a specific host on the internal network but anything is better than nothing.

If you want them to tunnel via ssh port forwarding, you can actually do this quite handily using only stuff built in to OpenSSH, and you won't need a restricted shell at all. All you need to do is set up an authorized key for each of the users to connect (or a shared one if they all have the same privs) and then use the authorized_keys directives to limit the power of the connection. As a simple example, you could put something like this before the keys:
permitopen="10.1.1.1:80",command="somecommand",no-X11-forwarding,no-agent-forwarding,no-pty ssh-dss AAA...

The permitopen only allows them to set up ssh port forwarding to that host and port. You can put multiple clauses if you want. In that case, they don't need shell access at all, and the command= specifies a command to run on connection. For somecommand some have suggested a simple script like this:
#!/bin/bash
tail -f /dev/null

or just using cat. In either case, the result is the same: they are forced to run a command that does nothing but are still allowed to initiate port forwarding to a specific host/port combination. Then just lock the user account using passwd so the user can't login normally with password auth.

Edit: the reason we need to run some command that just sits there forever and does nothing is because you are using Putty. If you were using the OpenSSH client, you could just set the command to /bin/true and the client could use ssh -Nf to simply set up forwarding in the background. Unless they've fixed it now, Putty will close the connection and the forwarding when the remote program returns.
 
cheesyking
Minister of Gerbil Affairs
Topic Author
Posts: 2756
Joined: Sun Jan 25, 2004 7:52 am
Location: That London (or so I'm told)
Contact:

Tue Mar 20, 2007 4:06 pm

cool thanks man, I knew there had to be a simpler way to do that.
Fernando!

Your mother ate my dog!
 
Hotwax
Gerbil
Posts: 73
Joined: Sun Feb 27, 2005 11:42 am
Location: Sweden
Contact:

Tue Mar 20, 2007 5:43 pm

great tip, bitvector! I've been needing to do basically the same thing, but was never convinced a restricted shell could be made very secure anyway. this seems like a very clean solution.
((lambda (x) (list x (list (quote quote) x))) (quote (lambda (x) (list x (list (quote quote) x)))))

Who is online

Users browsing this forum: No registered users and 20 guests
GZIP: On