nappingcat

Python framework for single-user SSH apis
Download

nappingcat Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Chris Dickinson
  • Publisher web site:
  • http://domain51.com

nappingcat Tags


nappingcat Description

Python framework for single-user SSH apis nappingcat is a django-inspired framework for routing single-user SSH calls.Useful for implementing software like gitosis.Installation# on the remote:sudo pip install nappingcatuseradd -m -U -s/bin/bash -r gitsudo su gitnappingcat_initconfcat id_rsa.pub > nappingcat_createsuperuser admin# on your local machinesudo pip install -e git+git://github.com/chrisdickinson/thundercat#egg=thundercatthundercat addremote < nickname > < git@remoteurl.com >thundercat add_permission admin kittygit create# now if you cd into a git repo...thundercat create_repo somerepo# it will create the repo on the remote server, and# ask if you want to add a remote.Developer commentsFor a while now i've been using gitosis -- it's really nice! but really, i had no idea how it worked. so over the last week i've been picking it apart, and i found that really, it's exposing a limited API around git using the ~/.ssh/authorized_keys file to automatically funnel all incoming commands through gitosis-serve, which then checks to see if everything looks kosher before sending things back through git. this is pretty cool! it'd be great if it had a little more functionality, though. nothing crazy -- no branch level permissions or anything -- just a bit more of the sugar from github proper. like being able to create repositories without having to edit a flat file, or being able to fork existing repositories.I realized that i really just wanted a way to write an extensible API for a single-user ssh system. it still seems weird, worded like that, but bare with me.This is the result, at the moment -- it's not done! it's experimental! nappingcat works on the same principle as gitosis, minus some core functionality at the moment. every ssh command coming through the user it's configured under will be passed through a command router that looks a lot like something you'd see in a django app.For example, from kittygit(the app I wrote as a proof-of-concept):From nappingcat.patterns import patternscmdpatterns = patterns('kittygit.handlers', (r'^kitty-git fork \'(?P\w+).git\'', 'fork_repo'), (r'^kitty-git create-repo \'(?P+)\'', 'create_repo'), (r'^git(?P+)', 'handle_git'),)Any ssh command that comes through will pass through those regexen until it finds a match, and then it'll delegate out to that function (that looks like the following:)def handle_git(request, action): # do things passNow, they're not required to return anything -- i'm leaning towards having whatever is returned passed back out through sys.stderr -- but you can see that a request object is passed in, and it contains the following:request.user # a string for the received usernamerequest.settings # a configparser instance of the settings filerequest.command # the original command interceptedrequest.std{in,out,err} # the std streamsrequest.auth_backend # a copy of the auth backend for the sessionthe settings are loaded from ~/nappingcat.conf. An example looks like the following:router = kittygit.patternsauth = nappingcat.contrib.sleazy_auth.SleazyAuthpaths = /Users/chris/projects/nappingcat /Users/chris/projects/kittygitThe router parameter defines a python module from which a variable named cmdpatterns can be imported. it looks like the above!The auth parameter defines a module to use for authentication. Right now it only has one backend -- 'sleazy_auth', which just says "yes" to everything. this is a big TODO.Note that you can nest cmdpatterns like in django:from nappingcat.patterns import patterns, includecmdpatterns = patterns('', (r'^', include('kittygit.patterns')),)So you can build up api's out of separate apps.Again, it's very very very beta. Requirements: · Python


nappingcat Related Software