Page MenuHomePhabricator

Prepare to route VCS connections through SSH
ClosedPublic

Authored by epriestley on Oct 26 2013, 5:04 PM.
Tags
None
Referenced Files
F13404435: D7419.diff
Fri, Jul 5, 1:23 PM
F13384779: D7419.id16712.diff
Sun, Jun 30, 6:35 PM
F13384726: D7419.id16746.diff
Sun, Jun 30, 6:13 PM
F13384718: D7419.id.diff
Sun, Jun 30, 6:11 PM
F13384708: D7419.diff
Sun, Jun 30, 6:07 PM
F13384706: D7419.diff
Sun, Jun 30, 6:07 PM
F13384562: D7419.id16712.diff
Sun, Jun 30, 5:10 PM
F13384560: D7419.id16746.diff
Sun, Jun 30, 5:10 PM
Subscribers

Details

Reviewers
btrahan
Maniphest Tasks
Restricted Maniphest Task
Restricted Maniphest Task
Commits
Restricted Diffusion Commit
rP888b3839e7e8: Prepare to route VCS connections through SSH
Summary

Fixes T2229. This sets the stage for a patch similar to D7417, but for SSH. In particular, SSH 6.2 introduced an AuthorizedKeysCommand directive, which lets us do this in a mostly-reasonable way without needing users to patch sshd (if they have a recent enough version, at least).

The way the AuthorizedKeysCommand works is that it gets run and produces an authorized_keys-style file fragment. This isn't ideal, because we have to dump every key into the result, but should be fine for most installs. The earlier patch against sshd passes the public key itself, which allows the script to just look up the key. We might use this eventually, since it can scale much better, so I haven't removed it.

Generally, auth is split into two scripts now which mostly do the same thing:

  • ssh-auth is the AuthorizedKeysCommand auth, which takes nothing and dumps the whole keyfile.
  • ssh-auth-key is the slightly cleaner and more scalable (but patch-dependent) version, which takes the public key and dumps only matching options.

I also reworked the argument parsing to be a bit more sane.

Test Plan

This is somewhat-intentionally a bit obtuse since I don't really want anyone using it yet, but basically:

  • Copy phabricator-ssh-hook.sh to somewhere like /usr/libexec/openssh/, chown it root and chmod it 500.
    • This script should probably also do a username check in the future.
  • Create a copy of sshd_config and fix the paths/etc. Point the KeyScript at your copy of the hook.
  • Start a copy of sshd (6.2 or newer) with -f <your config file> and maybe -d -d -d to foreground and debug.
  • Run ssh -p 2222 localhost or similar.

Specifically, I did this setup and then ran a bunch of commands like:

  • ssh host (denied, no command)
  • ssh host ls (denied, not supported)
  • echo '{}' | ssh host conduit conduit.ping (works)

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

From the test plan -- Really? -d -d -d isn't a typo?

-d = "debug", -d -d -d = "lots of debug"

:)

It enables "debug level 3" or somesuch.

Oh of course, debug level 3.... :D