[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: preserving ssh keys
- From: Eric Doutreleau int-evry fr
- To: kickstart-list redhat com
- Subject: Re: preserving ssh keys
- Date: Mon, 7 Apr 2003 15:35:16 +0200 (CEST)
On Thu, 3 Apr 2003 Eric Doutreleau int-evry fr wrote:
Well
i have begin to learn python to solve my problem.
Here is what i have done
As i m a total beginner in python i m sure there s a lot of
improvement which are possible.
Moreover there s a lot of assumption that have been made
-only ide disk
-only one disk
-no /var partition.
Thanks for all people that have answered to my question
in the kickstart file i have
%post --nochroot
chvt 3
(
mv -f /tmp/tempo/ssh_host_* /mnt/sysimage/etc/ssh
mv -f /tmp/tempo/local* /mnt/sysimage/var/cfengine/ppkeys
)
%pre --interpreter /usr/bin/python
import urllib, os
partition_script="/tmp/backupkey.py"
if not os.path.exists(partition_script):
url="ftp://crotale.int-evry.fr/pub/ks/backupkey.py"
urllib.urlretrieve(url, partition_script)
os.system('chmod 755 ' + partition_script)
os.system(partition_script)
And here is my backupkey.py script
#!/usr/bin/python
import os,sys,string
hds=""
mymedia=""
device=""
prefdev="/dev/"
tmproot="/tmp/root"
tmptempo="/tmp/tempo"
roo=""
va=""
numhd=0
for nomfichier in os.popen("ls -1d /proc/ide/h*/media").readlines():
print "NOMF" , nomfichier , "\n"
comm = "cat " + nomfichier
media=string.strip(os.popen(comm).readline())
if media == "disk":
parameters = string.split(nomfichier,"/")
print parameters
device= parameters[3]
print nomfichier, device , media , "\n"
numhd = numhd +1
print "NUMHD" , numhd
commande = "/usr/sbin/fdisk -l /dev/" + device + " | grep -i linux | grep -v Echange"
for ligne2 in os.popen(commande).readlines():
num=1
#print ligne2, "\n"
devi = string.split(ligne2," ")
part = devi[0]
comm="/usr/sbin/e2label " + part
for ligne3 in os.popen(comm).readlines():
l = ligne3[:-1]
if l == "/":
roo = part
if l == "/var":
va = part
print "LIGNE" , l , "\n"
print "ROOT" , roo, "VAR" , va , "\n"
if va == "/var":
print "deux partoches\n"
else:
comm = "mkdir " + tmproot
os.popen(comm)
comm = "mkdir " + tmptempo
os.popen(comm);
comm = "mount " + roo + " " + tmproot;
print comm , "\n"
os.popen(comm);
comm = "cp -a " + tmproot + "/etc/ssh/ssh_host_* " + tmptempo
print comm , "\n"
os.popen(comm)
comm = "cp -a " + tmproot +"/var/cfengine/ppkeys/localhost* " + tmptempo
print comm , "\n"
os.popen(comm);
comm = "umount " + tmproot
print comm , "\n"
os.popen(comm);
>
> hi
>
> i m wondering if someone has already written a %pre kickstart script
> to backup ssh keys in order to put them back in place in the post
> kickstart script.
>
> Thanks in advance for any help
>
>
>
>
--
Eric Doutreleau
I.N.T | Tel : +33 (0) 160764687
9 rue Charles Fourier | Fax : +33 (0) 160764321
91011 Evry France | email : Eric Doutreleau int-evry fr
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]