逐条注释 ``` getenforce setenforce 0 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 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 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-22 15:11:03 浏览: 331
详解Nginx启动失败的几种错误处理
以下是对每个命令的逐条注释:
```
getenforce
```
显示SELinux的执行模式。
```
setenforce 0
```
禁用SELinux。
```
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.service文件中的Type和ExecStart路径。
```
sed -i "s/GSSAPIAuthentication/#GSSAPIAuthentication/" /etc/ssh/sshd_config
```
注释掉sshd_config文件中的GSSAPIAuthentication行。
```
sed -i "s/GSSAPICleanupCredentials/#GSSAPICleanupCredentials/" /etc/ssh/sshd_config
```
注释掉sshd_config文件中的GSSAPICleanupCredentials行。
```
sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/" /etc/ssh/sshd_config
```
取消注释sshd_config文件中的PermitRootLogin行。
```
sed -i "s/#UsePAM yes/UsePAM yes/" /etc/ssh/sshd_config
```
取消注释sshd_config文件中的UsePAM行。
```
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
```
设置ssh_host_rsa_key、ssh_host_ecdsa_key和ssh_host_ed25519_key文件的权限为600。
```
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
```
备份并移动sshd和libcrypto.so.1.1文件,设置权限,并重新加载和重启sshd服务。
```
source /etc/profile
sshd -V
```
加载/etc/profile文件中的环境变量,并显示sshd的版本信息。
```
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
```
创建用户secure并设置密码,将用户secure加入sudoers文件,修改sshd_config文件以禁止root登录,重启sshd服务,并将用户secure的权限更改为无需输入密码执行任意命令,设置密码有效期限为99999天。
```
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
```
创建用户aqassoc并设置密码,创建/batshell目录并设置所有权和组,将用户aqassoc加入sudoers文件,运行/srv/script.sh脚本,延迟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
```
解压缩ssl-1.1.1o文件到/srv/目录,备份并移动openssl和openssl目录,备份和修改ld.so.conf文件,检查是否包含/srv/ssl-1.1.1o/lib/路径,刷新动态链接库缓存并显示包含"ssl"字符串的库,显示OpenSSL的版本信息。
```
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
```
删除/srv/root_password.sh和/srv/ssl-1.1.1o_7.tar.gz文件,并从指定URL下载initialization.sh脚本到/tmp/initialization.sh。
```
# 只有两个参数 dcn/dmz netbond/netskip baseline/baseskip
sh /tmp/initialization.sh dcn netbond/netskip baseline/baseskip
```
运行/tmp/initialization.sh脚本,并传递参数dcn、netbond/netskip和baseline/baseskip。
阅读全文