3 from TestSsh import TestSsh
7 def __init__ (self,test_plc,key_spec):
10 self.test_ssh=TestSsh(self.test_plc.test_ssh)
13 return self.key_spec['name']
16 return "keys/%s.pub"%(self.name())
17 def privatepath(self):
18 return "keys/%s.rsa"%(self.name())
20 def store_remote_key(self,hostname):
21 #Not tested yet, don't know if needed
23 priv=self.privatepath()
24 utils.header("Storing key %s in %s into %s "%(self.name(),pub,hostname))
25 dir=os.path.dirname(pub)
26 utils.system(self.test_ssh.to_host("mkdir %s"%dir))
27 utils.system(self.test_ssh.to_host("cat %s >> %s"%(self.key_spec['key_fields']['key'],pub)))
28 utils.system(self.test_ssh.to_host("cat %s >> %s"%(self.key_spec['private'],priv)))
29 utils.system(self.test_ssh.to_host("chmod %s 0400"%priv))
30 utils.system(self.test_ssh.to_host("chmod %s 0444"%pub))
34 priv=self.privatepath()
35 utils.header("Storing key %s in %s"%(self.name(),pub))
36 dir=os.path.dirname(pub)
37 if not os.path.isdir(dir):
40 f.write(self.key_spec['key_fields']['key'])
43 f.write(self.key_spec['private'])