Created
August 7, 2015 16:28
-
-
Save dictcp/b00bd0218ea9c575ed4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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