赞
踩
输入命令:hostnamectl
查看openssh的版本
输入命令:ssh -V
openssh-9.3p2.tar.gz、openssl-1.1.1t.tar.gz、zlib-1.2.13.tar.gz、及依赖包:
Gcc依赖包:
Pam_依赖包:
Pam-devel依赖包:
Perl依赖包:
telnet-server依赖包:
Xinetd依赖包:
使用工具连接至ssh服务器,我这里使用的是xshell的工具,全程操作保证root权限下且必须保持一个SSH会话不掉线执行。因此最好是提前安装好telnet。
输入命令:cd /tmp
输入命令:mkdir data
上传所有安装包及依赖包到data文件,利用xshell中的xftp上传
查看selinux状态,输入命令:sestatus
临时关闭selinux,输入命令:setenforce 0
永久关闭selinux,输入命令:vi /etc/selinux/config 进入编辑模式
输入命令:cd /tmp/data/yilai/telnet-server/
输入命令:rpm -ivh telnet-server-0.17-66.el7.x86_64.rpm
输入命令:cd /tmp/data/yilai/xinetd/
输入命令:rpm -ivh xinetd-2.3.15-14.el7.x86_64.rpm
输入命令:vi /etc/xinetd.d/telnet
写入一下内容:
service telnet
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
添加完成后:wq保存退出
输入命令:vi /etc/securetty
增加终端
pts/0
pts/1
pts/2
pts/3
输入命令:systemctl enable xinetd –now
输入命令:systemctl enable telnet.socket –now
输入命令:ss -luntp | grep 23
输入命令:firewall-cmd --zone=public --add-port=23/tcp –permanent
输入命令:firewall-cmd –reload
输入命令:firewall-cmd --zone=public --list-ports
输入命令:telnet ip 23(例:telnet 10.8.202.130 23)回车,输入账号密码成功登录
输入命令:mkdir -p /backup/openssl
mkdir /backup/openssh
切换到依赖包所在目录,并进入pam-devel文件夹
输入命令:cd /tmp/data/yilai/pam-devel/
执行安装命令:rpm -ivh pam-devel-1.1.8-23.el7.x86_64.rpm
切换到依赖包所在目录,并进入gcc文件夹
输入命令:cd /tmp/data/yilai/gcc /
执行安装命令:
rpm -ivh kernel-headers-3.10.0-1160.92.1.el7.x86_64.rpm
rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm
rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm
rpm -ivh glibc-* --replacefiles
rpm -ivh cpp-4.8.5-44.el7.x86_64.rpm
rpm -ivh gcc-4.8.5-44.el7.x86_64.rpm
从上到下依次执行
无报错为安装成功,有报错处理报错问题
切换到依赖包所在目录,并进入perl文件夹
输入命令:cd /tmp/data/yilai/perl/
执行安装命令:rpm -ivh *
切换到依赖包所在目录,并进入pam_文件夹
输入命令:cd /tmp/data/yilai/pam_
执行安装命令:
rpm -ivh boost-*
rpm -ivh boost-serialization-1.53.0-28.el7.x86_64.rpm
rpm -ivh snapper-*
rpm -ivh pcsc-lite-libs-1.8.8-8.el7.x86_64.rpm
rpm -ivh pam_krb5-2.4.8-6.el7.x86_64.rpm
rpm -ivh pam_pkcs11-0.6.2-30.el7.x86_64.rpm
rpm -ivh pam_snapper-0.2.8-4.el7.x86_64.rpm
rpm -ivh pam_ssh_agent_auth-0.10.3-2.22.el7_9.x86_64.rpm
rpm -ivh pam-devel-1.1.8-23.el7.x86_64.rpm
从上往下依次安装
无报错安装成功,否则处理报错。
输入命令:
cp /usr/lib64/libcrypto.so.10 /backup/openssl
cp /usr/lib64/libcrypto.so.1.0.2k /backup/openssl
cp /usr/lib64/libssl.so.10 /backup/openssl
cp /usr/lib64/libssl.so.1.0.2k /backup/openssl
输入命令:
mv /usr/bin/openssl /backup/openssl
输入命令:
mv /usr/include/openssl /backup/openssl/include_openssl
输入命令:
cp /etc/ld.so.conf /backup/openssl/etc_ld.so.conf
输入命令: rm -rf /etc/ssl
切换至data目录
输入命令:
cd /tmp/data
tar -xf openssl-1.1.1t.tar.gz
切换到openssl-1.1.1t文件夹中
输入命令:
cd openssl-1.1.1t
./config shared --prefix=/usr/local/ssl
若无报错则继续执行,否则处理报错问题
输入命令:make && make install
这里需要等一会。等待编译完成后:
输入命令:echo $? (返回0代表编译安装成功)
输入命令:
echo "/usr/local/ssl/lib">>/etc/ld.so.conf
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -sf /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib" >/etc/ld.so.conf.d/openssl.conf
ldconfig
从上到下依次执行
输入命令:openssl version
输入命令:
cd /tmp/data
tar -xf zlib-1.2.13.tar.gz
cd zlib-1.2.13/
./configure --prefix=/usr/local/zlib
make && make install (需要等带一段时间)
编译完成输入下面命令,返回0说明成功
echo $?
输入命令:mv /etc/ssh /backup/openssh
备份pam.d/sshd 文件
输入命令:mv /etc/pam.d/sshd /backup/openssh
输入命令:rpm -qa | grep openssh
输入命令:rpm -e --nodeps `rpm -qa | grep openssh`
输入命令:
cd /tmp/data/
tar -xzvf openssh-9.3p2.tar.gz
输入命令:cd openssh-9.3p2
输入命令:./configure --prefix=/usr/local/ssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl --with-zlib=/usr/local/zlib --with-md5-passwords --with-pam
输入命令: make && make install
编译完成输入下面命令,返回0说明成功
echo $?
输入命令:
ln -sf /usr/local/ssh/libexec /usr/libexec/openssh
ln -sf /usr/local/ssh/sbin/sshd /usr/sbin/sshd
ln -sf /usr/local/ssh/bin/scp /usr/bin/scp
ln -sf /usr/local/ssh/bin/ssh /usr/bin/ssh
ln -sf /usr/local/ssh/bin/ssh-add /usr/bin/ssh-add
ln -sf /usr/local/ssh/bin/ssh-agent /usr/bin/ssh-agent
ln -sf /usr/local/ssh/bin/ssh-keygen /usr/bin/ssh-keygen
ln -sf /usr/local/ssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
在openssh的解压文件下执行:
输入命令:
cd /tmp/data/openssh-9.3p2
cp contrib/redhat/sshd.init /etc/init.d/sshd
cp contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
cp contrib/ssh-copy-id /usr/bin/ssh-copy-id
输入命令:chmod 755 /usr/bin/ssh-copy-id
输入命令:
cp /backup/openssh/ssh/sshd_config /etc/ssh/
y
cp /backup/openssh/ssh/ssh_config /etc/ssh/
y
cp /backup/openssh/sshd /etc/pam.d
输入命令:
echo "KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1" >> /etc/ssh/sshd_config
输入命令:vi /etc/ssh/sshd_config
# 取消PubkeyAuthentication yes 的注释
:PubkeyAuthentication yes
# 若UsePAM yes 默认被注释 则关闭注释
UsePAM yes
输入命令:vi /etc/ssh/ssh_config
# 将GSSAPIAuthentication yes注释掉
#GSSAPIAuthentication yes
# 保存并退出
输入命令:
mv /backup/openssl/libcrypto.so.10 /usr/lib64/libcrypto.so.10
y
mv /backup/openssl/libssl.so.10 /usr/lib64/libssl.so.10
y
输入命令:chkconfig sshd on
输入命令:/etc/init.d/sshd start
输入命令:ssh -V
输入命令:
systemctl disable xinetd --now
systemctl disable telnet.socket --now
输入命令:
firewall-cmd --zone=public --remove-port=23/tcp –permanent
输入命令:firewall-cmd –reload
输入命令:firewall-cmd --zone=public --list-ports
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。