SFTP access by username or group membership?

I need to be able to restrict SFTP access to a short list of users on my server. Right now, anyone who has AFP or SMB access to the server can also connect via SFTP, this is not what we need.

Is there a way to restrict SFTP access to a list of approved users or (better yet) to a single group?

OSXS 10.4.10

thank you

Posted on Sep 11, 2007 7:38 PM

Reply
6 replies

Sep 11, 2007 7:42 PM in response to mattor

Also - we are not stuck on SFTP. We used SFTP because it's secure and easy to set up. turn on FTP server, turn on "remote access" in the sharing control panel and bingo, SFTP. Not sure what else is involved in using other secure variations of FTP. One issue with SFTP is the chroot problem. We are using cyberduck as an FTP client and we can set up a path that will help our user from shuffling through the entire boot drive, but it would be better to have them just land in the shared volume directly.

Any suggestions are appreciated.

Sep 11, 2007 8:57 PM in response to mattor

There is no relationship between FTP and SFTP.

SFTP is a subset of SSH, not FTP, and therefore it's available to anyone who's able to ssh into the server.

You can (and should?) disable the FTP service unless you have some other use for it.

As for SFTP, the question hinges around two things - first, are you running a central directory server, or does each user have a local account on the machine? and second, do the users need shell access on the server for any other purpose?

The reason I ask is that since SFTP runs under SSH, you can use any of the SSH controls to manage access. The first one that comes to mind is AllowGroups (or, potentially, AllowUsers).

Using either of these directives will allow you to restrict access to SSH/SFTP to specific users and/or groups.

In that way you could create a group for your users (if you don't already) and then tell SSH that only that group (or list of users) are allowed to connect. For example, if you created a group called 'sshUsers' and put all the users who should be able to SSH or SFTP to the server into that group, you can then add the line:

<pre class=command>AllowGroup sshUsers</pre>

to /etc/sshd_config on your server to restrict access to that group only.

The reason I ask about the central directory is because if you're running a directory, you just need to add the group there. If the server has local accounts, though, then you need to add it in the local directory. It's not a big difference either way, just a matter of where you make the change.

Sep 12, 2007 3:17 AM in response to Camelot

first, are you running a central directory server, or does each user have a local account on the >machine? and second, do the users need shell access on the server for any other purpose?

It is a single server environment, as an open directory master (leaving room for expansion), only one local user (not an active user, just a server admin account), the others are all in the 192.168.2.20 LDAP directory.

None of the users need shell access for any reason at all. I didn't want anyone using straight FTP since they will sit at the coffee shop open wireless and ftp into the server, not good. I knew that SFTP would be secure transmission of data and password/credentials.

The reason I ask about the central directory is because if you're running a directory, you just need >to add the group there.


where is the /etc/sshd_config directory located for a directory other than the local one?

Since I don't need shell access for my users, would it be better to just set up FTP-SSL? I haven't seen any good explanation of how to set up ftp-ssh or any other version of secure ftp. Any suggestions on setting that up or where to go for information? It would be great to not have the whole chroot problem that we have now with SFTP.

That would be my preference from what you have said here.

thanks a lot for the help. I will put the "allowgroup" fix in place until I can learn more about the ftp-ssl idea.

thanks again

Sep 12, 2007 9:26 AM in response to mattor

where is the /etc/sshd_config directory located for a directory other than the local one?


I'm not sure what you're asking here. /etc/sshd_config is the path to the file.
You can't see this in the Finder, if that's where you're looking, since /etc is a hidden directory, so you'll need to use the terminal.

As for the chroot issue, just change the user's home directory to the directory you want them to upload to. It isn't the same as chroot since they can still manually navigate to other parts of the system, but at least it will eliminate any confusion over where to upload things.

Lastly, for now, I don't think I've ever seen FTP-SSL implemented with the built-in FTP server. I know there are third-party servers that implement it, so that may be the path you have to take. Just make sure that you can set it in FTPS-only mode otherwise users will be able to log in insecurely anyway - just having an option to use SSL isn't enough to ensure most people actually use it.

Sep 12, 2007 8:22 PM in response to Camelot

Setting up SFTP/SSH ACLs is considerably easier with 10.4. In ServerAdmin, connect to your server, do NOT choose a specific server, choose the Settings tab in the bottom right and the Access tab in the upper right. You can filter access to any service by users & groups here.

Also, sorry to say, but giving someone SFTP access is the same as shell access. There are ways around this which are very complex... either patching OpenSSH or the use of a specilized shell called scponly. Do a search for ssh and chroot or jail and you will see much information about it. I check in every year or so to see if it's more possible, but seemingly, it isn't.

Like Camelot, I have not seen any info for FTP/SSL with OS X server either.

Sep 13, 2007 9:54 AM in response to jaydisc

Guys,

thanks a ton for the helpful directions. I adjusted the SSH_config file, and that worked to limit the group access. But the solution through the Server admin program seems to be an easier one for my sys admin to manage without any hassle. That one works as well to limit SSH and FTP users. Also cool that I can limit the windows user access from there as well. Great tip.

less than 2 days to a full solution. You guys are great.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

SFTP access by username or group membership?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.