³ò
òýIc           @   s)  d  Z  d d k Z d d k Z d d k Z d d k l Z l Z l Z l Z l	 Z	 e
 d j oÆd Z e d e i ƒ Z e d e i ƒ Z e e i ƒ Z d Z e i i e i d	 d
 ƒ Z e i i e d ƒ Z d Z e p¢ e i i e i d ƒ d Z e i i e ƒ on e e d ƒ i ƒ  Z e e j oH e i e ƒ Z e i d e ƒ Z e i d e ƒ Z e e d e !Z qzq~n e d j o e d e i ƒ Z n e d j oR e d e d e ƒ Z e d j o e d GHe i  ƒ  n e i d ƒ d Z n: e i i e e ƒ Z e i i e ƒ p e e d GHn e pŒ e e g Z e	 e i ƒ Z! e" e! ƒ d j o e i# e! ƒ n e" e ƒ d j o e i# e d ƒ n e e d e GHe i$ e e ƒ n e e d e ƒ Z e i d ƒ d j Z% e% o& e i i e i d	 d ƒ Z& d Z' n# e i i e i d	 d ƒ Z& d Z' e i i( e& ƒ p e e& d GHe i  ƒ  n e i) e& ƒ g  Z* xz e i+ d ƒ D]i Z! e! i e' ƒ d j oM e i i, e! ƒ d d  j o, e i i- e! d  ƒ o e* i. e! ƒ qùqýq”q”We" e* ƒ d j oº e i i e i i e ƒ d d! ƒ Z/ e d" e/ GHe e/ d# e ƒ Z e% o e' Z* e* d  Z0 qâe i1 ƒ  e' d$ d% e i2 d d& ƒ Z* e* d  Z0 e i3 e' e* ƒ e i3 e' d  e0 ƒ n e* d Z* e* d  Z0 e d' e d( e* GHe% o2 d) Z4 e e0 d ƒ i ƒ  Z5 e5 i d ƒ d Z5 n  d* e* Z! e i i d+ ƒ oA e d+ d ƒ i ƒ  Z e i e! ƒ d j o e e! d 7Z q”n d Z e d+ d, ƒ i6 e ƒ d- Z4 e e0 d ƒ i ƒ  Z5 d. e0 Z! e d Z7 x;e7 D]3Z d/ e d0 GHe% oN e d e d1 d2 e4 d3 d4 e5 d5 e4 d6 d7 d8 e5 d9 e4 d: Z8 nc d; e0 d< e d e d1 d= e0 d3 d2 e4 d3 d4 e! d5 e4 d3 d7 d8 e! d9 e4 d: Z8 e e8 e ƒ e i i( e ƒ p e i9 e ƒ n e i i e e ƒ Z e i i: e ƒ o( e i i- e ƒ p e i; e ƒ q+n e i i: e ƒ p e i< e i d e ƒ n e d j o­ e i i e ƒ od e e d ƒ i ƒ  Z e e j o> e i e ƒ Z e i d e ƒ Z e d e !e e d Z qãn d Z e e d e d 7Z e e d, ƒ i6 e ƒ qàqàWe i  ƒ  n d S(>   so  
#+
# NAME:
#	ssh_to
# PURPOSE:
#	Simplify login between accounts on subnet
# CATEGORY:
#	ucsd/gen/python
# CALLING SEQUENCE:
#	ssh_to <-init> <user@host> <user2@host2> <...>
# INPUTS:
#	user@host	account for which ssh access is needed
#			(if the user name on the remote host is
#			the same as on the account from which
#			ssh_to is executed then 'user@ can be
#			omitted.
# OPTIONAL INPUT PARAMETERS:
#	-init		if specified it must be the first command
#			line argument. Initializes ssh access
#			to the remote account (see PROCEDURE).
# OUTPUTS:
#	(private/public key pair; updates of local 'identification'
#	file and remote 'authorization' file(s))
# OPTIONAL OUTPUT PARAMETERS:
# CALLS:
#	tiny.is_there, tiny.args, tiny.start, tiny.run_cmd, tiny.keys
# RESTRICTIONS:
# >	Assumes that ssh2 creates 2048 bit dsa keys
#	with key name id_dsa_2048_a for the private key
#	and id_dsa_2048_a.pub for the public key.
# >	Assumes that ~/.ssh2 already exists on the remote
#	machines.
# >	For the soft links to work ~/bin must be in the path.
# EXAMPLE:
#	ssh_to -init user@host		(initializes user@host)
#	user@host			(logs into user@host)
# PROCEDURE:
#	If -init is set:
#	1. Check for private key of type id_dsa_2048_a_*.
#	2. If the private key does not exist, then run
#	   ssh-keygen2 to generate private key id_dsa_2048_a
#	   and public key id_dsa_2048_a.pub. Rename the key
#	   pair to id_dsa_2048_a_$RANDOM(.pub).
#	3. Put private key in .ssh2/identification
#	4. Loop over all hosts, and for each
#	   a. put the public key in remote ~/.ssh2 directory,
#	   b. put the name of the public key in remote ~/.ssh2/authorization.
#	   c. put a link to ssh2_to in ~/bin 
# MODIFICATION HISTORY:
#	JUL-2004, Paul Hick (UCSD/CASS)
#	JAN-2004, Paul Hick (UCSD/CASS)
#		Converted from bash to Python.
#	FEB-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
#		Improved lookup of files with private keys.
#-
iÿÿÿÿN(   t   is_theret   argst   startt   run_cmdt   keyst   __main__s   ssh_to, s   -verboses   -initt   ssht   HOMEt   bins
   ssh_to.txtt    i    i   t   rt   =s   
s   -bin=s   which s    2> /dev/nulls   ssh not founds	   not foundt    s    -V 2>&1t   OpenSSHs   .ssht   id_dsas   .ssh2t   id_dsa_2048_as    does not existt   .s   .pubs
   ssh-keygens   generating key with s    -t dsat   _s   %05diŸ† s   using s
    with key s   .ssh/authorized_keyss   IdKey t   identificationt   ws   .ssh2/authorizations   Key s
   

Set up: s   

s    "s   touch s   ; s   grep \"s   \" s    > /dev/null; s    if [ \$? == 0 ]; then exit; fi; s   echo \"s   \" >> t   "s   cat s    | s   cat - > .ssh2/(=   t   __doc__t   ost   syst   randomt   tinyR    R   R   R   R   t   __name__t   sayt   argvt   verboset   initt   argR   t   patht   joint   environR   t   txtt   ssh_bint   splitt   hostt   isfilet   opent   readt   tmpt   findt   pbegt   pendt   exitt   keyt   lent   extendt   execvpt   open_ssht   ssh_dirt   prefixt   isdirt   chdirt   privatet   listdirt   splitextt   existst   appendt   keygent   publict   seedt   randintt   renamet   autht   valt   writet   hostst   cmdt   mkdirt   islinkt   removet   symlink(    (    (    s	   ssh_to.pys   <module>9   sè   $(	
 %






 C
[!