first commit
This commit is contained in:
2
WsConfman/confman/hostlist/192.168.2.100
Normal file
2
WsConfman/confman/hostlist/192.168.2.100
Normal file
@ -0,0 +1,2 @@
|
||||
first_start
|
||||
jb{RWfnu
|
2
WsConfman/confman/hostlist/192.168.2.163
Normal file
2
WsConfman/confman/hostlist/192.168.2.163
Normal file
@ -0,0 +1,2 @@
|
||||
first_start
|
||||
>X1nr0.E
|
60
WsConfman/confman/managemnt.sh
Executable file
60
WsConfman/confman/managemnt.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#(c) Roy Cohen 12/06/2017 :roy@wondercohen.nl
|
||||
#original script :My own work
|
||||
#objective :Linux workstation configration manger
|
||||
#last update :
|
||||
#version
|
||||
|
||||
|
||||
#Varibles
|
||||
CLIENT_ARR=( `sudo tail -50 /var/log/secure | grep "Did not receive identification string from" |cut -d " " -f12| sort | uniq` )
|
||||
CLIENT_PATH="$HOME/confman/hostlist/"
|
||||
CLIENT=(`ls $CLIENT_PATH`)
|
||||
|
||||
# Functions
|
||||
function add_client {
|
||||
#Check if the client is known and add the cilent if it is not known in the system
|
||||
for client in "${CLIENT_ARR[@]}"; do
|
||||
if [ -f $CLIENT_PATH$client ] ; then
|
||||
echo "$CLIENT_PATH$client already exists"
|
||||
else
|
||||
echo "" > $CLIENT_PATH$client
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function add_ssh_ECDSA {
|
||||
#Check if the client is known and add the ssh ECDSA key fingerprint to ~/.ssh/known_hosts
|
||||
for client in "${CLIENT[@]}"; do
|
||||
grep "$client" $HOME/.ssh/known_hosts > /dev/null
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo " $client already known at ~/.ssh/known_hosts"
|
||||
else
|
||||
ssh-keyscan $client >> ~/.ssh/known_hosts
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
#ssh root@$CLIENT "md5sum /etc/ssh/sshd_config"
|
||||
#Check if first_start.sh as run on the client, if not than copy the first_start.sh to the client and run it
|
||||
function first_start {
|
||||
#FIST_START=`head -1 $CLIENT_PATH$CLIENT`
|
||||
|
||||
for cilent in "${CLIENT[@]}"; do
|
||||
head -1 $CLIENT_PATH$cilent | grep first_start > /dev/null
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "$cilent has allready run first_start"
|
||||
else
|
||||
scp ~/confman/scripts/first_start.sh root@$cilent:/root && echo "first_start" > $CLIENT_PATH$cilent
|
||||
ssh root@$cilent '/root/first_start.sh' >> $CLIENT_PATH$cilent && ssh root@$cilent 'rm /root/first_start.sh'
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#call funcions
|
||||
add_client
|
||||
add_ssh_ECDSA
|
||||
first_start
|
9
WsConfman/confman/scripts/first_start.sh
Executable file
9
WsConfman/confman/scripts/first_start.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
PASS=`< /dev/urandom tr -dc A-Za-z0-9'"<>,./?!@#$%^&(){}[]' | head -c8`
|
||||
oldPassword="Test2001"
|
||||
newPassword=$PASS
|
||||
rootdevice="/dev/sda3"
|
||||
printf '%s\n' "$oldPassword" "$newPassword" "$newPassword" |sudo cryptsetup luksAddKey $rootdevice
|
||||
printf '%s\n' "$oldPassword" |sudo cryptsetup luksRemoveKey $rootdevice
|
||||
echo $newPassword
|
Reference in New Issue
Block a user