curl -s -L https://gist.githubusercontent.com/cmadera/6c2d0bab1560cd04a49e4adc53ff3dc1/raw/59686f48e573ec0c56a3c27afa479d5402002281/first-setup.sh | bash or rm first-setup.sh cat > first-setup.sh << "EOF" #!/bin/bash echo "source: https://opensource.com/article/20/1/improve-bash-scripts" if [ "$USER" != 'root' ]; then echo "Sorry, this script must be run as root and you are $USER" exit 1 fi read -p "enter a user please:" USERNAME echo $user read -p "enter a password please:" PASSWORD echo $password ########################## echo "Setup UPGRADE" apt update -y && apt upgrade -y apt install sudo ########################## echo "Create user" read -p "Add new User? [Y/n]: " answuser if [ "$answuser" == 'y' ]; then useradd -m -p $(openssl passwd -1 ${PASSWORD}) -s /bin/bash -G sudo ${USERNAME} echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers fi ########################## echo "Setup SSH Config" read -p "Apply ssh security? [Y/n]: " answsec if [ "$answsec" == 'y' ]; then ### SSH Config cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp sed '/MaxAuthTries/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config echo "MaxAuthTries 3" >> /etc/ssh/sshd_config grep "^MaxAuthTries" /etc/ssh/sshd_config cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp sed '/PermitRootLogin/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config echo "PermitRootLogin no" >> /etc/ssh/sshd_config grep "^PermitRootLogin" /etc/ssh/sshd_config /etc/init.d/ssh restart fi ########################## echo "Install Basics" apt install -y curl git net-tools build-essential tmux screen apt install -y neofetch apt install -y cockpit ########################## echo "Setup .bash_aliases" if [ "$answuser" == 'y' ]; then if [ -f /home/${USERNAME}/.bash_aliases ]; then rm /home/${USERNAME}/.bash_aliases fi echo "alias get='sudo apt-get install -y'" >> /home/${USERNAME}/.bash_aliases echo "alias df='df -h'" >> /home/${USERNAME}/.bash_aliases echo "alias ls='ls -la'" >> /home/${USERNAME}/.bash_aliases echo "alias upgrade='sudo apt-get update -y && sudo apt-get full-upgrade -y && sudo apt-get autoremove -y'" >> /home/${USERNAME}/.bash_aliases echo "alias cdwww='cd /var/www/html'" >> /home/${USERNAME}/.bash_aliases echo "alias myip='curl ifconfig.me'" >> /home/${USERNAME}/.bash_aliases echo "alias version='lsb_release -a'" >> /home/${USERNAME}/.bash_aliases sudo chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.bash_aliases fi EOF bash first-setup.sh
sábado, 6 de fevereiro de 2021
Debian server configurator
domingo, 26 de julho de 2020
Install MySQL on Debian
# Check here: https://dev.mysql.com/downloads/repo/apt/ wget http://repo.mysql.com/mysql-apt-config_0.8.16-1_all.deb sudo dpkg -i mysql-apt-config_0.8.16-1_all.deb sudo apt update sudo apt install mysql-server sudo systemctl restart mysql sudo mysql_secure_installation mysql -u root -p
Install PHP 7.3 on Debian 9 / Debian 8
sudo apt -y install lsb-release apt-transport-https ca-certificates sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list sudo apt update sudo apt -y install php7.3
Common Alias
For Debian
vi .bashrc
For CentOS
vi .bashrc
vi .bashrc
alias get='sudo apt-get install -y'
alias df='df -h'
alias ls='ls -la'
alias upgrade='sudo apt-get update -y && sudo apt-get autoremove -y'
alias cdwww='cd /var/www/html'
alias myip='curl ifconfig.me'
alias version='lsb_release -a'
For CentOS
vi .bashrc
alias get='sudo yum install -y' alias df='df -h' alias ls='ls -la' alias upgrade='sudo yum update -y' alias cdwww='cd /var/www/html' alias myip='curl ifconfig.me' alias version='hostnamectl'
Debian Upgrade
## First check version
cat /etc/debian_version
uname -a
## From Debian 8 (jessie) to 9 (stretch)
sed -i 's/jessie/stretch/g' /etc/apt/sources.list
apt update -y && apt upgrade -y
apt dist-upgrade
apt autoremove
reboot
## From Debian 9 (stretch) to 10 (buster)
sed -i 's/stretch/buster/g' /etc/apt/sources.list
apt update -y && apt upgrade -y
apt dist-upgrade
apt autoremove
reboot
cat /etc/debian_version
uname -a
## From Debian 8 (jessie) to 9 (stretch)
sed -i 's/jessie/stretch/g' /etc/apt/sources.list
apt update -y && apt upgrade -y
apt dist-upgrade
apt autoremove
reboot
## From Debian 9 (stretch) to 10 (buster)
sed -i 's/stretch/buster/g' /etc/apt/sources.list
apt update -y && apt upgrade -y
apt dist-upgrade
apt autoremove
reboot
sábado, 25 de julho de 2020
First server configuration
apt update -y && apt upgrade -y
apt install sudo
### Create user
export USERNAME='user'
export PASSWORD='userpassword'
useradd -m -p $(openssl passwd -1 ${PASSWORD}) -s /bin/bash -G sudo ${USERNAME}
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
### SSH Config
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp
sed '/MaxAuthTries/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config
echo "MaxAuthTries 3" >> /etc/ssh/sshd_config
grep "^MaxAuthTries" /etc/ssh/sshd_config
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp
sed '/PermitRootLogin/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
grep "^PermitRootLogin" /etc/ssh/sshd_config
/etc/init.d/ssh restart
### Install the Basics
apt install curl git net-tools build-essential tmux screen
sexta-feira, 27 de junho de 2014
Source
Install EPEL (Extra Packages for Enterprise Linux.)
# wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm
Install Apache:
# yum install httpd -y
Start the Apache service and let it to start automatically on every reboot:
# service httpd start
# chkconfig httpd on
Install MySQL
# yum install mysql mysql-server -y
Start the MySQL service and make to start automatically on every reboot.
# service mysqld start
# chkconfig mysqld on
Setup MySQL root password
By default, mysql root user doesn’t has password. To secure mysql, we have to setup mysql root user password.
# mysql_secure_installation
Install PHP
# yum install php -y
Restart httpd service:
# service httpd restart# yum install php-mysql -y
Install EPEL (Extra Packages for Enterprise Linux.)
# wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm
# yum repolist
Now install phpMyAdmin
# yum install phpmyadmin -y
Edit the phpmyadmin.conf file.
# vi /etc/httpd/conf.d/phpMyAdmin.conf
Find and comment the whole /<Directory> section as shown below:
# cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php # vi /usr/share/phpMyAdmin/config.inc.php
Change cookie to http.
Restart the Apache service:
# service httpd restart
Assinar:
Postagens (Atom)