升级系统
apt-get update && apt-get --fix-broken install && apt-get autoremove
安装 telnet 服务端
在 root 下安装
apt install xinetd && apt-get install openbsd-inetd telnetd telnet -y
启动服务
/etc/init.d/openbsd-inetd restart
查看服务是否启动
netstat -anpt | grep 23
使用 telnet 连接
telnet ip
所需工具
apt-get install build-essential
安装 OpenSSL
# 下载源码包
wget --no-check-certificate https://www.openssl.org/source/openssl-3.2.0.tar.gz
# 解压
tar -zxvf openssl-3.2.0.tar.gz
# 进入目录
cd openssl-3.2.0/
# 配置
./config --prefix=/usr/local/openssl shared
# 编译
make
# 安装
make install
wget --no-check-certificate https://www.openssl.org/source/openssl-3.2.0.tar.gz && tar -zxvf openssl-3.2.0.tar.gz && cd openssl-3.2.0/ && ./config --prefix=/usr/local/openssl shared && make && make install
软链接
ln -s /usr/local/openssl/lib64/libssl.so.3 /usr/lib/
ln -s /usr/local/openssl/lib64/libcrypto.so.3 /usr/lib/
确保 OpenSSL 可以使用
/usr/local/openssl/bin/openssl version
## 安装 Zlib
```bash
# 下载源码包
wget --no-check-certificate http://www.zlib.net/zlib-1.3.1.tar.gz
# 解压
tar -zxvf zlib-1.3.1.tar.gz
# 进入目录
cd zlib-1.3.1/
# 预编译
./configure --prefix=/usr/local/zlib
# 编译
make
# 安装
make install
wget --no-check-certificate http://www.zlib.net/zlib-1.3.1.tar.gz && tar -zxvf zlib-1.3.1.tar.gz && cd zlib-1.3.1/ && ./configure --prefix=/usr/local/zlib && make && make install
所需依赖
apt-get -y install libz-dev
安装 OpenSSH
# 卸载旧版本
apt purge --remove "openssh*"
# 清除旧版本进程
killall sshd
# 下载源码包
wget --no-check-certificate https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz
# 解压
tar -zxvf openssh-9.6p1.tar.gz
# 进入目录
cd openssh-9.6p1/
# 编译配置
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-zlib-dir=/usr/local/zlib --without-openssl-header-check
# 编译
make
# 安装
make install
# 如果出现Privilege separation user sshd does not exist:
# 需要添加 `sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin` 到 `/etc/passwd`
echo "sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin" >> /etc/passwd
# 并重新执行
make install
sudo apt purge --remove "openssh*" && killall sshd && wget --no-check-certificate https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz && tar -zxvf openssh-9.6p1.tar.gz && cd openssh-9.6p1/ && ./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-zlib-dir=/usr/local/zlib --without-openssl-header-check && make && make install
手动启动 OpenSSH
/usr/local/openssh/sbin/sshd
将 OpenSSH 注册为服务
vim /usr/lib/systemd/system/sshd.service
# 添加以下内容:
[Unit]
Description=OpenSSH serve
Documentation=man:sshd(8) man:sshd_config(5)
#After=network.target sshd-keygen.service
#Wants=sshd-keygen.service
After=network.target
[Service]
#Type=notify
#EnvironmentFile=/etc/sysconfig/sshd
#ExecStart=/usr/local/openssh/sbin/sshd -D $OPTIONS
ExecStart=/usr/local/openssh/sbin/sshd
#ExecReload=/bin/kill -HUP $MAINPID
#KillMode=process
#Restart=on-failure
#RestartSec=42s
[Install]
WantedBy=multi-user.target
重载 Systemctl, 并设置为自启动
systemctl daemon-reload
systemctl start sshd.service
systemctl enable sshd
查看服务是否启动
systemctl status sshd
netstat -anpt | grep 22
查看版本
sudo ln -s /usr/local/openssh/bin/ssh /usr/local/bin/ssh
ssh -V
启动 root 登陆(可选)
vim /etc/ssh/sshd_config
# 修改以下内容:
PermitRootLogin yes
# 重启服务
systemctl restart sshd
标签:sshd,p1,20,--,openssl,usr,&&,最新版,local From: https://www.cnblogs.com/tangllty/p/18054446尝试登陆,成功!