Skip to content

Instantly share code, notes, and snippets.

@jesboat
Last active April 21, 2020 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesboat/e25c452a97a2ebcd08df6e05f52aa66b to your computer and use it in GitHub Desktop.
Save jesboat/e25c452a97a2ebcd08df6e05f52aa66b to your computer and use it in GitHub Desktop.
bash -c '
if [ "$(whoami)" = root ]; then
echo "No, you are supposed to run this bit as non-root"
exit 1
fi
sudo -v
pass=$(openssl rand -hex 16 | sed -e "s/\\(....\\)/\\1-/g; s/-\$//")
echo "Chosen random password: $pass"
{
echo "root:$pass"
echo "$(whoami):$pass"
} | sudo chpasswd
sudo sh -c "
apt-get update
apt-get upgrade
apt-get -y install screen openssh-server
service sshd start"
echo
echo "Remote access is set up."
echo "Account:"
echo " $(whoami) : $pass"
echo "Addresses:"
ip addr | sed -e "/^ *inet/ b p; d; :p s/^ */ /"
echo "SSH fingerprints:"
for k in /etc/ssh/ssh_host*.pub; do
ssh-keygen -lf $k | sed -e "s/^/ "
done
echo
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment