``` getenforce#查看SELinux 安全机制 setenforce 0#将 SELinux 的执行模式从强制模式(Enforcing)切换为宽松模式(Permissive) cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.old.service sed -i -e 's/^Type=.*/Type=simple/g' -e '/ExecStart=/{s/\/usr\/sbin\/sshd/\/usr\/local\/sbin\/sshd/g}' /usr/lib/systemd/system/sshd.service#将文件中以"Type="开头的行替换为"Type=simple";包含"ExecStart="的行中,将"/usr/sbin/sshd"替换为"/usr/local/sbin/sshd" sed -i "s/GSSAPIAuthentication/#GSSAPIAuthentication/" /etc/ssh/sshd_config#将/etc/ssh/sshd_config文件中的"GSSAPIAuthentication"替换为"#GSSAPIAuthentication" sed -i "s/GSSAPICleanupCredentials/#GSSAPICleanupCredentials/" /etc/ssh/sshd_config sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/" /etc/ssh/sshd_config sed -i "s/#UsePAM yes/UsePAM yes/" /etc/ssh/sshd_config chmod 600 /etc/ssh/ssh_host_rsa_key chmod 600 /etc/ssh/ssh_host_ecdsa_key chmod 600 /etc/ssh/ssh_host_ed25519_key mv /usr/local/sbin/sshd /usr/local/sbin/sshd.old202211 mv /lib64/libcrypto.so.1.1 /lib64/libcrypto.so.1.1.old202211 mv /srv/libcrypto.so.1.1 /lib64/ mv /srv/sshd /usr/local/sbin/ chmod 755 /usr/local/sbin/sshd chmod 755 /lib64/libcrypto.so.1.1 systemctl daemon-reload systemctl restart sshd.service source /etc/profile sshd -V useradd secure echo 'Ofm#6%3%fm0IWH'|passwd --stdin secure echo "secure ALL=(ALL) ALL" >> /etc/sudoers sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config service sshd restart systemctl daemon-reload systemctl restart sshd.service sed -i "s/secure ALL=(ALL) ALL/secure ALL=(ALL) NOPASSWD: ALL/" /etc/sudoers chage -M 99999 secure sleep 2 useradd aqassoc echo 'dAxgDt^7LT' | passwd --stdin aqassoc mkdir /batshell chown -R aqassoc:aqassoc /batshell echo 'aqassoc ALL=(ALL) NOPASSWD:ALL,!/bin/su,!/sbin/init,!/sbin/shutdown,!/sbin/halt,!/sbin/reboot,!/usr/sbin/visudo,!/usr/bin/passwd' >> /etc/sudoers sh /srv/script.sh sleep 2 tar -xvf /srv/ssl-1.1.1o* -C /srv/ mv /usr/bin/openssl /usr/bin/openssl.old mv /usr/include/openssl /usr/include/openssl.old cp /etc/ld.so.conf /etc/ld.so.conf.old ln -s /srv/ssl-1.1.1o/bin/openssl /usr/bin/openssl ln -s /srv/ssl-1.1.1o/include/openssl /usr/include/openssl srvlib=`cat /etc/ld.so.conf | grep '/srv/ssl-1.1.1o/lib/' | wc -l` if [ $srvlib -eq 0 ];then sed -i 's/\/srv/#\/srv/'g /etc/ld.so.conf echo '/srv/ssl-1.1.1o/lib/' >> /etc/ld.so.conf else echo 'ssl-1.1.1n is ok!' fi ldconfig -v |grep ssl openssl version rm -rf /srv/root_password.sh rm -rf /srv/ssl-1.1.1o_7.tar.gz curl --connect-timeout 10 -# http://133.64.86.246/iso/shell/initialization.sh -o /tmp/initialization.sh # 只有两个参数 dcn/dmz netbond/netskip baseline/baseskip sh /tmp/initialization.sh dcn netbond/netskip baseline/baseskip ```
时间: 2023-07-17 19:09:07 浏览: 260
这段代码看起来是一系列的命令,用于进行系统配置和安装操作。请注意,这些命令可能会对系统进行重要的更改和安装软件包,因此在运行之前,请确保你对这些操作有充分的了解,并且在适当的环境中执行。
以下是这段代码的逐行解释:
```bash
getenforce # 查看 SELinux 安全机制
setenforce 0 # 将 SELinux 的执行模式从强制模式(Enforcing)切换为宽松模式(Permissive)
# 备份 sshd.service 文件
cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.old.service
# 修改 sshd.service 文件内容
sed -i -e 's/^Type=.*/Type=simple/g' -e '/ExecStart=/{s/\/usr\/sbin\/sshd/\/usr\/local\/sbin\/sshd/g}' /usr/lib/systemd/system/sshd.service
# 修改 sshd_config 文件内容
sed -i "s/GSSAPIAuthentication/#GSSAPIAuthentication/" /etc/ssh/sshd_config
sed -i "s/GSSAPICleanupCredentials/#GSSAPICleanupCredentials/" /etc/ssh/sshd_config
sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/" /etc/ssh/sshd_config
sed -i "s/#UsePAM yes/UsePAM yes/" /etc/ssh/sshd_config
# 修改文件权限
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
# 移动文件和更改权限
mv /usr/local/sbin/sshd /usr/local/sbin/sshd.old202211
mv /lib64/libcrypto.so.1.1 /lib64/libcrypto.so.1.1.old202211
mv /srv/libcrypto.so.1.1 /lib64/
mv /srv/sshd /usr/local/sbin/
chmod 755 /usr/local/sbin/sshd
chmod 755 /lib64/libcrypto.so.1.1
systemctl daemon-reload
systemctl restart sshd.service
source /etc/profile
sshd -V
# 创建用户 secure,并设置密码,配置 sudo 权限
useradd secure
echo 'Ofm#6%3%fm0IWH' | passwd --stdin secure
echo "secure ALL=(ALL) ALL" >> /etc/sudoers
sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
service sshd restart
systemctl daemon-reload
systemctl restart sshd.service
sed -i "s/secure ALL=(ALL) ALL/secure ALL=(ALL) NOPASSWD: ALL/" /etc/sudoers
chage -M 99999 secure
sleep 2
# 创建用户 aqassoc,并设置密码,创建目录并设置权限,配置 sudo 权限,执行脚本
useradd aqassoc
echo 'dAxgDt^7LT' | passwd --stdin aqassoc
mkdir /batshell
chown -R aqassoc:aqassoc /batshell
echo 'aqassoc ALL=(ALL) NOPASSWD:ALL,!/bin/su,!/sbin/init,!/sbin/shutdown,!/sbin/halt,!/sbin/reboot,!/usr/sbin/visudo,!/usr/bin/passwd' >> /etc/sudoers
sh /srv/script.sh
sleep 2
# 解压 ssl-1.1.1o.tar.gz 文件,并设置软链接,配置 ld.so.conf
tar -xvf /srv/ssl-1.1.1o* -C /srv/
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
cp /etc/ld.so.conf /etc/ld.so.conf.old
ln -s /srv/ssl-1.1.1o/bin/openssl /usr/bin/openssl
ln -s /srv/ssl-1.1.1o/include/openssl /usr/include/openssl
srvlib=`cat /etc/ld.so.conf | grep '/srv/ssl-1.1.1o/lib/' | wc -l`
if [ $srvlib -eq 0 ];then
sed -i 's/\/srv/#\/srv/'g /etc/ld.so.conf
echo '/srv/ssl-1.1.1o/lib/' >> /etc/ld.so.conf
else
echo 'ssl-1.1.1n is ok!'
fi
ldconfig -v | grep ssl
openssl version
# 清理临时文件
rm -rf /srv/root_password.sh
rm -rf /srv/ssl-1.1.1o_7.tar.gz
# 下载并执行 initialization.sh 脚本
curl --connect-timeout 10 -# http://133.64.86.246/iso/shell/initialization.sh -o /tmp/initialization.sh
# 执行 initialization.sh 脚本,传递参数
sh /tmp/initialization.sh dcn netbond/netskip baseline/baseskip
```
请确保你对这些命令的含义和可能的影响有清楚的了解,并在合适的环境中运行它们。
阅读全文