#注释版本:
# 创建用户
adduser centos7
# 必要依赖安装
yum install -y epel-release.noarch lrzsz wget tcping nload curl htop
# 上传证书 or 创建 or 下载
cd /home/centos7/
# rz or wget
wget http://127.0.0.1/sshkey.tgz
# 解压缩 密钥
tar -xzvf sshkey.tgz
# 授权用户目录
chown -R centos7 /home/centos7/
# 授权root权限且切换免密
echo 'centos7 ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# 修改ssh 端口 --可选
# echo 'Port 10022' >> /etc/ssh/sshd_config
# 开启密钥登录
echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
# 关闭密码登录
sed -i "s#PasswordAuthentication yes#PasswordAuthentication no#g" /etc/ssh/sshd_config
# 重启ssh 服务
systemctl restart sshd.service
# 设置hostname
hostnamectl --static set-hostname $(curl http://121.196.209.144/server/open/hostname) && hostname
#简洁版本:
adduser centos7
yum install -y epel-release.noarch lrzsz wget tcping nload curl htop
cd /home/centos7/
wget http://127.0.0.1/sshkey.tgz
tar -xzvf sshkey.tgz
chown -R centos7 /home/centos7/
echo 'centos7 ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
sed -i "s#PasswordAuthentication yes#PasswordAuthentication no#g" /etc/ssh/sshd_config
systemctl restart sshd.service
hostnamectl --static set-hostname $(curl http://121.196.209.144/server/open/hostname) && hostname