一、为了预防安装出错,打开telnet远程登录
apt-get install telnetd xinetd
查看状态
service xinetd status
默认使用root账号不能登录
创建一个用户,
adduser zhang
写入密码其他默认即可
添加到sudo组
adduser zhang sudo
关闭telnet远程登录
/etc/init.d/openbsd-inetd stop
二、升级openssh
1、安装依赖包
apt install libzip-dev libssl-dev autoconf gcc libxml2 make
2、下载源码文件包
cd /usr/local/src
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1.tar.gz --no-check-certificate
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf openssh-7.9p1.tar.gz
tar -zxvf openssl-1.1.1.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
3、编译安装zlib
cd zlib-1.2.11
./configure --prefix=/usr/local
make
make install
4、编译安装openssl
apt purge openssl
cd ../openssl-1.1.1
./config shared --prefix=/usr/local/ssl
make test
make install
ln -s /usr/local/ssl/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
ln -s /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
5、编译安装openssh
service sshd stop
apt purge ssh
cd ../openssh-7.9p1
./configure --prefix=/usr/local --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/ssl
make
make install
6、设置相关配置文件
mv /usr/bin/scp /tmp/;mv /usr/bin/ssh* /tmp/
ln -s /usr/local/bin/ssh /usr/bin/ssh
ln -s /usr/local/bin/scp /usr/bin/scp
ln -s /usr/local/bin/ssh-add /usr/bin/ssh-add
ln -s /usr/local/bin/ssh-agent /usr/bin/ssh-agent
ln -s /usr/local/bin/ssh-keygen /usr/bin/ssh-keygen
ln -s /usr/local/bin/ssh-keyscan /usr/bin/ssh-keyscan
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/sbin/sshd /usr/bin/sshd
7、重启ssh服务
service sshd restart
8、查看当前版本
ssh -V
sshd -V
openssl version -a
网友评论