#!/bin/bash# 更新系统包索引
echo "更新系统包索引..."
sudo yum update -y# 安装X11相关的应用和认证工具
echo "安装X11相关的应用和认证工具..."
sudo yum install -y xorg-x11-apps xorg-x11-xauth# 检查和修改/etc/ssh/sshd_config以允许X11转发
echo "检查和配置SSH以允许X11转发..."# 检查X11Forwarding是否设置为yes
X11Forwarding=$(grep "^X11Forwarding" /etc/ssh/sshd_config)
if [ "$X11Forwarding" == "X11Forwarding yes" ]; thenecho "X11Forwarding已经设置为yes。"
elseecho "设置X11Forwarding为yes。"sudo sed -i 's/^#X11Forwarding no/X11Forwarding yes/' /etc/ssh/sshd_configsudo sed -i 's/^X11Forwarding no/X11Forwarding yes/' /etc/ssh/sshd_config
fi# 检查X11UseLocalhost是否设置为no
X11UseLocalhost=$(grep "^X11UseLocalhost" /etc/ssh/sshd_config)
if [ "$X11UseLocalhost" == "X11UseLocalhost no" ]; thenecho "X11UseLocalhost已经设置为no。"
elseecho "设置X11UseLocalhost为no。"sudo sed -i 's/^#X11UseLocalhost yes/X11UseLocalhost no/' /etc/ssh/sshd_configsudo sed -i 's/^X11UseLocalhost yes/X11UseLocalhost no/' /etc/ssh/sshd_config
fi# 重启SSH服务
echo "重启SSH服务以应用更改。"
sudo systemctl restart sshd
# 安装OpenGL相关的图形库
echo "安装OpenGL相关的图形库..."
sudo yum install -y mesa-libGL mesa-libGL-devel# 安装zstd压缩算法的开发库
echo "安装zstd压缩算法的开发库..."
sudo yum install -y libzstd-develsudo yum install -y bluez-libs-devel# 安装文泉驿正黑字体
echo "安装文泉驿正黑字体..."
sudo yum install -y wqy-zenhei-fonts# 设置系统区域设置为简体中文
echo "设置系统区域设置为简体中文..."
sudo localectl set-locale LANG=zh_CN.UTF-8echo "依赖安装完毕。"
IP_ADDR=$(hostname -I | awk '{print $1}')
# 提示用户重新连接服务器
echo "请重新连接服务器。。。"
echo "使用以下命令通过SSH重新连接,并启用X11转发:"
echo "ssh -XY $IP_ADDR"
1.复制如上代码到shell脚本
- 运行脚本即可
bash test.sh