Created
July 14, 2013 10:44
-
-
Save nansenat16/5993899 to your computer and use it in GitHub Desktop.
auto generated root password from mac address with installer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kickstart file automatically generated by anaconda. | |
install | |
text | |
cdrom | |
lang en_US.UTF-8 | |
keyboard us | |
%include /tmp/rootpw | |
authconfig --enableshadow --passalgo=sha512 | |
%pre --interpreter /usr/bin/python --log=/root/ks-pre.log --erroronfail | |
# | |
# http://www.wanware.com/tsgdocs/snack.html | |
# http://www.trueblade.com/techblog/user-input-during-a-fedora-kickstart | |
import os,sys,io | |
from snack import SnackScreen,ButtonChoiceWindow | |
def set_tty(n): | |
f = open('/dev/tty%d' % n, 'a') | |
os.dup2(f.fileno(), sys.stdin.fileno()) | |
os.dup2(f.fileno(), sys.stdout.fileno()) | |
os.dup2(f.fileno(), sys.stderr.fileno()) | |
def rootpwd(txt): | |
pw_return="" | |
tmp=0 | |
pw_str=txt.split(":")*2 | |
for i in range(4): | |
s=(int(pw_str[11-i],16)-tmp)%26+65 | |
pw_return+=unichr(s) | |
tmp=(int(pw_str[11-i],16)+s)%7 | |
for i in range(4): | |
s=(int(pw_str[7-i],16)-tmp)%26+97 | |
pw_return+=unichr(s) | |
tmp=(int(pw_str[7-i],16)+s)%7 | |
for i in range(4): | |
s=(int(pw_str[3-i],16)-tmp)%10+48 | |
pw_return+=unichr(s) | |
tmp=(int(pw_str[7-i],16)+s)%7 | |
return pw_return | |
#rootpw | |
eth0_line=int(os.popen("ip link|grep -nr \"eth0\"|awk -F: '{print $1}'").read()) | |
eth0_mac=os.popen('ip link|sed -n '+str(eth0_line+1)+"p|awk '{print $2}'").read() | |
pwd=rootpwd(eth0_mac) | |
io.open("/tmp/rootpw","w").write(u"rootpw "+pwd) | |
set_tty(1) | |
screen=SnackScreen() | |
ButtonChoiceWindow(screen,"Root Password","Your eth0 mac : "+eth0_mac+"\n Password : "+pwd,["OK"]) | |
screen.finish() | |
set_tty(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's interesting to see how you recreate the user-interface in python to communicate with the user. However I would simply add public keys to /root/.ssh/authorized_keys in order have access to newly provisioned systems. This seems to be insecure, since the kickstart-files usually are public.