23 lines
1.2 KiB
Bash
Executable File
23 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
dpkg-reconfigure openssh-server
|
|
# my_username=$(shuf -n 1 /etc/workshopnames.yml | cut -b 3-)
|
|
# udhcpc -i eth0 -x hostname:$(hostname) -F $(hostname)
|
|
# # once we have our IP, create the matching user.
|
|
# my_last_octet=$(ip -4 a s dev eth0 | grep / | cut -f 4 -d . | cut -f 1 -d /)
|
|
my_last_octet=$(( $(hostname | tr -cd '0-9') )) ## just keep the numbers from the hostname
|
|
# ip addr replace dev eth0 192.168.0.${my_last_octet}/24
|
|
# ip route replace default via 192.168.0.1
|
|
udhcpc -i eth0 -x hostname:$(hostname) -F $(hostname) -r 192.168.0.${my_last_octet} # request .1 for linux1, etc. GW should be .254
|
|
my_username_pwhash=$(sed -n "${my_last_octet}{p;q}" /etc/workshopnames.yml)
|
|
my_username="${my_username_pwhash%%:*}"
|
|
my_pwhash_pwd="${my_username_pwhash#*: }"
|
|
my_pwhash=${my_pwhash_pwd%%,*}
|
|
my_pwd=${my_pwhash_pwd#*,}
|
|
useradd -m ${my_username} -p "${my_pwhash}" -s /bin/bash
|
|
su - ${my_username} -c 'mkdir .ssh'
|
|
echo "$my_pwd" > /home/${my_username}/PASSWORD
|
|
# cp /root/.ssh/authorized_keys /home/${my_username}/.ssh/ && chown ${my_username}:${my_username} /home/${my_username}/.ssh/authorized_keys
|
|
printf "172.16.202.33\tjumphost1\n" >> /etc/hosts
|
|
su - ${my_username} -c "echo 'alias fireworks=\"fireworks.sh Fireworks\"' >> ~/.bash_aliases"
|
|
/usr/sbin/sshd -D
|