initial
This commit is contained in:
17
setups/linux.sh
Executable file
17
setups/linux.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/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_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
|
||||
/usr/sbin/sshd -D
|
||||
Reference in New Issue
Block a user