初始化脚本
脚本内容 适用于Debian10版本的基础环境脚本
#! /bin/bash
ENS=ens33
IP=$1
DNS=$2
HOST=$3
apt install -y vim tree ssh bash-completion less net-tools man
sed -i '35,41s/^#//' /etc/bash.bashrc
sed -i '11,12s/^/#/' /etc/network/interfaces
sed -i '32s/^#//' /etc/ssh/sshd_config
sed -i 's#prohibit-password#yes#g' /etc/ssh/sshd_config
cat>>/etc/bash.bashrc<<EOF
alias re='systemctl restart'
alias st='systemctl status'
alias an='apt install -y'
alias 6='init 6'
alias 0='init 0'
alias dp='ifdown ens33 && ifup ens33'
alias fl='ip addr flush ens33'
EOF
cat>>/etc/network/interfaces<<EOF
auto $ENS
iface $ENS inet static
address $IP
gateway 192.168.10.254
EOF
cat>/etc/resolv.conf<<EOF
nameserver $DNS
EOF
rm /etc/hostname
echo $HOST >> /etc/hostname
reboot
脚本使用方法
source 脚本名称.sh ip/24 dns 主机名