关闭防火墙
# 关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
# 关闭selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# cat /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
挂载iso源作为本地源
# 挂载iso 镜像到 /mnt目录
mount /dev/cdrom /mnt
# 避免其他源影响建议使用本地源的之前清空 repo 文件
rm -f /etc/yum.repos.d/*
# 按照下面配置iso源
vi /etc/yum.repos.d/Centos-Media.repo
[media-BaseOS]
name=media-BaseOS
baseurl=file:///mnt/BaseOS #源存放路径
gpgcheck=0 #关闭校验
enabled=1 # 开启源
[media-AppStream]
name=media-AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0
enabled=1
# 清空 yum 缓存
yum clean all
# 生成缓存
yum makecache
制作依赖包的镜像源
# 安装源制作工具
yum -y install yum-utils createrepo
# 创建repo源存储目录
mkdir ssh-update
# 下载依赖包
cd ssh-update
repotrack openssl
repotrack openssl-devel
repotrack make
repotrack telnet
repotrack telnet-server
repotrack xinetd
# 工具包(非必要下载)
repotrack vim
repotrack net-tools
# 生成yum源
cd ..
createrepo ssh-update/
#将ssh-update打包即可上传到其他内网服务器上使用
tar -zcvf ssh-update.tar.gz ssh-update/
安装离线升级所需yum源
# 解压包
tar -zxvf ssh-update.tar.gz -C /root
# 在内网服务器参考以下配置ssh-update源 建议将其他源备份删除
vi /etc/yum.repos.d/ssh-update.repo
[ssh-update]
name=ssh-update
baseurl=file:///root/ssh-update
gpgcheck=0
enabled=1
# 清空 yum 缓存
yum clean all
# 生成缓存
yum makecache
安装依赖及工具
yum -y install gcc openssl openssl-devel make telnet telnet-server xinetd vim net-tools
配置并开启telnet服务
# 没有的话创建
[root@localhost ~]# cat /etc/xinetd.d/telnet
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
# 重启xinetd服务
[root@localhost ~]# systemctl restart xinetd
# 查看telnet 23端口是否启动
[root@localhost ~]# netstat -ntlp |grep 23
升级OpenSSH
# 查看旧版本的openssh
[root@localhost ~]# rpm -qa|grep openssh
# 卸载旧版本
[root@localhost ~]# rpm -e --nodeps openssh
[root@localhost ~]# rpm -e --nodeps openssh-clients
[root@localhost ~]# rpm -e --nodeps openssh-server
解压安装
1
# 解压
tar -zxvf openssh-8.9p1.tar.gz
cd openssh-8.9p1
# 安装
install -v -m700 -d /var/lib/sshd &&
chown -v root:sys /var/lib/sshd &&
groupadd -g 50 sshd &&
useradd -c 'sshd PrivSep' \
-d /var/lib/sshd \
-g sshd \
-s /bin/false \
-u 50 sshd
2
./configure --prefix=/usr \
--sysconfdir=/etc/ssh \
--with-md5-passwords \
--with-privsep-path=/var/lib/sshd &&
make
3
make install
4
# 赋权
chmod 600 /etc/ssh/ssh_host_ed25519_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_rsa_key
make install
# 查看版本
ssh -V
配置root
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo 'X11Forwarding yes' >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
配置系统服务
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
chkconfig --list sshd
# 重启服务
systemctl restart sshd
# 查看状态
systemctl status sshd
参考
https://slxsyy.com/p/linux0/