Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42890

Library to work with SSH public keys

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <phatbuckett@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'python.': 0.02; 'attributes': 0.09; 'subject:keys': 0.09; 'type,': 0.09; 'api': 0.11; 'formatted': 0.16; 'keys)': 0.16; 'length,': 0.16; 'need:': 0.16; 'skip:9 40': 0.16; 'ssh': 0.16; 'twisted': 0.16; 'library': 0.18; 'looked': 0.18; 'bit': 0.19; 'trying': 0.19; 'python?': 0.22; 'shell': 0.22; 'parse': 0.24; "i've": 0.25; 'equivalent': 0.26; 'this:': 0.26; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'keys': 0.31; "user's": 0.31; 'this.': 0.32; '(e.g.': 0.33; 'comment': 0.34; "i'd": 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'doing': 0.36; "didn't": 0.36; 'to:addr:python-list': 0.38; 'anything': 0.39; 'obtain': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'commands': 0.60; 'solve': 0.60; 'break': 0.61; 'length': 0.61; 'simple': 0.61; 'email addr:gmail.com': 0.63; 'information': 0.63; 'such': 0.63; 'capable': 0.67; 'as:': 0.81; 'comment.': 0.84; 'pycrypto': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=phveRcS6G4aYs+AXAqLHLNwoSALpjiLeXi6/EJhVhKY=; b=J8JNqOhSBLq3Gm5HndxNO8i59Cg2+GiGC3JJLOT7clVBsz1jipj6sh5+ODywX2yqhp UXs6oJSDSb0GJ59kD5NiSgHuJSasj1KeXqM9k670RIdEyevAJE1QtxPe4hxVzv9tq2BL Pu+NjCn2RJpP5rZokPELJIyYCnP0at32jIDw/9z5bvh+O97pfpYXAh0qNOKDWajiMI3U vlAEV4KcuLSZgLStlfzVyclFkmmb4UCcm1+jAvWYgBLzOxlO8fdBYBr29r4UiQcRsTeb PEeiy4ngtu6/ZyUCXIGYVZVCOAjbafJ8H5lcqa7rFyaavPAjfTueTtwoENqsj5u2rv7/ xy/g==
MIME-Version 1.0
X-Received by 10.50.114.37 with SMTP id jd5mr1469506igb.2.1365227367031; Fri, 05 Apr 2013 22:49:27 -0700 (PDT)
Date Fri, 5 Apr 2013 22:49:26 -0700
Subject Library to work with SSH public keys
From Darren Spruell <phatbuckett@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.187.1365227369.3114.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365227369 news.xs4all.nl 6843 [2001:888:2000:d::a6]:38383
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42890

Show key headers only | View raw


I'd like to work with user submitted/uploaded SSH public keys from
Python. I'm trying to solve what I'd thought might be a simple need:
given a user's OpenSSH formatted _public_ key (RSA, or DSA, or
whatever), how do you obtain information about it such as: key type
(e.g. ssh-rsa, etc.); bit length (e.g. 2048); key comment (e.g.
user@hostname); key fingerprint? I've been fiddling with the Paramiko
API and looked at PyCrypto (supports OpenSSH keys) and Twisted Conch
but didn't see anything that looked like it did this.

I'm looking for the equivalent to this:

$ ssh-keygen -l -f tmp.key.pub
2048 9b:31:06:6a:a4:79:97:33:d7:20:15:1f:cd:b4:86:4d dspruell@Sydney.local (RSA)

...to get the attributes of the public key: key type, bit length,
fingerprint and comment.

Is there an SSH library capable of doing this from Python? Can break
out to shell commands to parse them but I'd prefer not to.

-- 
Darren Spruell
phatbuckett@gmail.com

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Library to work with SSH public keys Darren Spruell <phatbuckett@gmail.com> - 2013-04-05 22:49 -0700
  Re: Library to work with SSH public keys Roy Smith <roy@panix.com> - 2013-04-06 08:49 -0400
    Re: Library to work with SSH public keys Darren Spruell <phatbuckett@gmail.com> - 2013-04-07 00:51 -0700

csiph-web