How to add root to the ssh users

I was running 10.3.9 server. I moved to 10.5 server (now 10.5.2) and I was having trouble to get the following setup to work, or to find out what was keeping it from working (tried debugging, but that did not bring me any further).

The setup is as follows: a normal user can run a command to sync /usr/local hierarchies via sudo. The way this is set up:
- enable root on the server
- change sshd_config so root can do forced-commands only
- have a ~root/.ssh/authorized_keys file with contents like
command="rsync --server --daemon .",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-dss [key removed] client@clientsystem
- setup /etc/rsyncd.conf with
[localstuff]
path = /usr/local
comment = whole /usr/local tree
hosts allow = [ip addresses of local hosts that may do this]
hosts deny = *
uid = root
gid = staff
read only = no

Thn, on the client, the client runs (to sync /usr/local/src to the server):

sudo /usr/bin/rsync --rsync-path=/usr/bin/rsync -E --progress -avu --dry-run \
-e "ssh -v -v -i /Users/client/.ssh/rsync-private-key -l root" \
""/usr/local/src/ \
server::localstuff/src/

After the first sudo, however, I get three requests for Password after which the command fails. This used to work. The three failed attempts do not give a lot of information about what is causing this.

While writing this I thought of the solution, however. I also have limited ssh access to my server (in System Preferences) to a few users and hence root could not ssh into my server at all (ssh and rsync are not really helpful with their error messages).

I solved making root ssh-able by adding group com.apple.access_ssh to user System Administrator in Workgroup Manager: Local, so now root can ssh into my server (of course only using the private key and then only running into the forced-command of my rsync server).

So, I thought I post this for some others who might run into the same thing: "how to add root to the ssh users".

Still, enabling root and opening up ssh and enabling root ssh-usage must be about one of the most dangerous things to do, security wise. However, I do need root-owned stuff in /usr/local (e.g. Package Maker maintained stuff or stuff I want protected against normal users) so I need root to be able to sync this. I think there is no more secure way to do this, but maybe I missed options? Note: it should also work when one system is off line (e.g. laptop), hence using mounts is out of the question. "Mobile /usr/local Sync" would be nice 😉

500Mhz G4 Cube w Radeon 9000, 120GB Seagate, 1.2GHz G4 iBook, DTK

Posted on May 18, 2008 3:37 PM

Reply
4 replies

May 18, 2008 8:20 PM in response to Gerben Wierda

That's just nasty, allowing ssh as root.

Why not do the ssh as a different user, and on the target system have a launchd-based watch sript
that takes items in a specified folder, and moves them to /usr/local and sets appropriate permissions ?

You should also edit
/etc/sshd_config

and disallow password auth

PasswordAuthentication no
PermitEmptyPasswords no

+and further down+:

UsePAM no

And I'd also setup a wrapper script as well. See
http://www.bombich.com/mactips/rsync.html
"(Optionally) Limit the remote client's access to rsync only"

May 19, 2008 8:23 AM in response to davidh

I agree it is nasty to have ssh access for root. But in this case:
- only access for the rsync --server command set in authorized_keys
- rsyncd config only allows access from a few selected internal IP addresses, these are behind a NAT/firewall setup and not accessible from the outside (not easily).
- only access with a public/private key pair
So I think it will be difficult to get in, unless sshd itself is broken and in that case all bets are off anyway.

The ssh/launchd script is not an option for me. /usr/local is 17GB on my system and when an update occurs I do not know what has been updated. Sometimes 3GB of that 17GB needs to be updated (after serious builds/changes), sometimes 20kB. All of it can change in unpredictable ways and all those changes need to be synchronized to a few systems. Permissions change on the source files and should be followed on the destination. Syncing is both ways. In short, the non-root ssh+script is unmaintainable an unusable in my case.

I already have the other sshd settings you suggest (I only set UsePam to yes sometimes for short intervals when I need it), the other two are Apple defaults.

May 22, 2008 1:40 PM in response to Mabel O'Farrell

The quotes are the result of the way I run this: via a makefile

hedwig:~ gerben$ make -n put-localsrc
make DELETE="" SUBDIR=src put-local
hedwig:~ gerben$ make -n DELETE="" SUBDIR=src put-local
sudo /usr/bin/rsync --rsync-path=/usr/bin/rsync -E --progress -avu --exclude=TeXLive-working-copy/ --exclude=context-update/ --exclude=.Spotlight-V100/ \
-e "ssh -i /Users/gerben/.ssh/id_rsync -l root" \
""/usr/local/src/ \
vanroodewierda::usrlocal/src/

The "" is the effect of a variable there (ROOTVOL, for which root volume I want to sync) being empty. As the variable may contain whitespace, it needs to be protected with quotes.

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.

How to add root to the ssh users

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