image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old July 28th, 2004, 10:45 PM
macidiot's Avatar
Registered User
 
Join Date: Jul 2001
Location: OH
Posts: 225
Thanks: 0
Thanked 0 Times in 0 Posts
macidiot is on a distinguished road
Question Allowing only certain users to ssh

I recently added a user account for a friend so that he could host a small website on my server. I want him to have ftp access, but no ssh access. I have been searching on the web for about an hour or so, and I think my answer lies in adding a "allowuser" command in the ssh_config file, but I can't seem to find a whole lot of info on how to use it.

What do I need to do to only allow ssh access to two users (and not him)?

Thanks,
Macidiot
Reply With Quote
  #2  
Old July 29th, 2004, 12:10 AM
michaelsanford's Avatar
Psycholinguist
 
Join Date: Oct 2002
Location: Ottawa/Montrιal
Posts: 2,174
Thanks: 0
Thanked 0 Times in 0 Posts
michaelsanford is on a distinguished road
The simplest way to accomplish this is to give him no shell (or more specifically, a null shell).

1. Open /Applications/Utilities/NetInfo Manager;
2. Select /Users/him in the three panes;
3. Click the lock, if locked, so you can make changes;
4. Change the value of "shell" to "/usr/bin/false";
5. Hit APPLE-S to save changes, saying yes to any messages about updating local domains, etc. Then under the Management menu, choose Restart Local NetInfo Domains for the changes to take effect;

This next step is important if you want your user still to have FTP access:
In a terminal window type cat /etc/shells and check to see if /usr/bin/false is listed. As you can see from the comment at the top of that file, if the shell is not listed there then the user won't be allowed to log in over FTP.

If it's not listed, add it by typing sudo pico /etc/shells scroll down to the end of the list and type it in. Type CTRL-X to quit, pressing "y" to save, hitting ENTER to use the original file name.

Since FTPd is called from xinetd on OS X only when someone tries to connect, you won't need to restart it since FTPd doesn't run all the time.

PS While in NetInfo Manager you can also move his home directory, if it would be useful to do so to, say, another partition.
__________________
michaelsanford.com • Blog • Twitter • Tumblr • LinkedIn
• iMac Aluminum 24" |
MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD
• iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD
• AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2•120 GB RAID 1, 2•500 GB RAID 0
Reply With Quote
  #3  
Old July 29th, 2004, 04:49 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
check the sshd_config manpage.

You're right that that's what you want, the AllowUsers directive. Basically, all you do is put a line in /etc/sshd_config like

AllowUsers somebody somebodyelse

any user whose username is not somebody or somebodyelse will then be disallowed from connecting to ssh
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #4  
Old July 29th, 2004, 05:44 PM
Official Volunteer
 
Join Date: Oct 2000
Location: UAF, Fairbanks, AK
Posts: 409
Thanks: 0
Thanked 0 Times in 0 Posts
macavenger is on a distinguished road
Would there, by any chance, be a coresponding DenyUsers directive, if you have more people you want to allow than deny? Just curious.
__________________
iMac 17" FP 800MHZ/1024MB/75GB/SuperDrive/OS X 10.4.x
PowerMac G4 450 DP/256MB/30GB/OS X 10.4.x
Olympus C-5500 5.0 MP/5x Optical zoom Digital Camera
Reply With Quote
  #5  
Old July 29th, 2004, 06:29 PM
Registered User
 
Join Date: Oct 2002
Posts: 281
Thanks: 0
Thanked 0 Times in 0 Posts
pedz is on a distinguished road
There is AllowUsers AllowGroups DenyUsers and DenyGroups. There are patterns.

Do sshd_config to google and pick the one that says sshd_config(5)

I wonder why Mac OS X doesn't have those man page.
Reply With Quote
  #6  
Old July 29th, 2004, 08:41 PM
macidiot's Avatar
Registered User
 
Join Date: Jul 2001
Location: OH
Posts: 225
Thanks: 0
Thanked 0 Times in 0 Posts
macidiot is on a distinguished road
Do I need to restart to make this active, or is there another way? I added denyusers, but it still lets the account log in via ssh
Reply With Quote
  #7  
Old July 29th, 2004, 09:26 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
on OS X the ssh server doesn't listen as a daemon, it is activated by xinetd for each new connection - what that means is, once you change the config file, it will be read from scratch for every new connection - no need to restart anything
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #8  
Old July 30th, 2004, 01:03 AM
Registered User
 
Join Date: Sep 2001
Location: Tokyo, Japan
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
legacyb4 is on a distinguished road
For what it's worth, I prefer the AllowUsers approach instead as you are explicitly allowing a single user (you) and denying all others access.

Kind of like telling a bouncer to keep everyone out except for me rather than to watch out for that seedy little guy who keeps trying to get in.

Cheers.

Quote:
Originally Posted by macidiot
Do I need to restart to make this active, or is there another way? I added denyusers, but it still lets the account log in via ssh
__________________
Macbook (Black) C2D/120GB/2GB | G5/1.6 250GBx2/1.25GB
Free Mobile Phone Ringtone, Application, & Screensaver Uploader
Reply With Quote
Reply

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 10:52 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.