Skip to content

Instantly share code, notes, and snippets.

@dictcp
Created August 7, 2015 16:28
Show Gist options
  • Save dictcp/b00bd0218ea9c575ed4d to your computer and use it in GitHub Desktop.
Save dictcp/b00bd0218ea9c575ed4d to your computer and use it in GitHub Desktop.
#!/bin/bash
# enable root login & password login
sed -i 's/^[# ]*PermitRootLogin$/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^[# ]*PasswordAuthentication$/PasswordAuthentication yes/' /etc/ssh/sshd_config
/etc/init.d/ssh restart > /dev/null
/etc/init.d/sshd restart > /dev/null
echo '-----------------------------------------'
if [ "`cat /etc/shadow | grep root | cut -d: -f2`" == '!*' ]; then
password=`dd if=/dev/urandom bs=1 count=320 2> /dev/null | tr -dc a-z2-9 | head -c8`
echo "root:$password"|chpasswd
echo "Your root account is ready."
echo "Username: root"
echo "Password: $password"
echo '-----------------------------------------'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment