1、openssh注意事项
- 升级过程会卸载openssh,连接窗口千万不要关闭,最好开2个连接窗口。
2、下载openssh源码包
# 官网下载路径
https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/
# 本次下载路径
https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.6p1.tar.gz
3、安装依赖包
$ yum install openssl-devel zlib-devel gcc gcc-c++ make -y
4、查找现有版本openssh的pid位置
$ find / -name sshd.pid
5、 卸载旧版openssh
$ rpm -e --nodeps $(rpm -qa|grep openssh)
$ mkdir /etc/ssh/bk && mv /etc/ssh/* /etc/ssh/bk/
6、上传openssh源码
$ pwd
/opt/soft
$ rz
7、解压&编译&安装
--prefix 安装目录
--sysconfdir 配置文件目录
--with-ssl-dir 指定 OpenSSL 的安装目录
--with-privsep-path 非特权用户的chroot目录
--with-privsep-user=sshd 指定非特权用户为sshd
--with-zlib 指定zlib库的安装目录
--with-md5-passwords 支持读取经过MD5加密的口令
--with-ssl-engine 启用OpenSSL的ENGINE支持
$ cd /opt/soft
$ tar xf openssh-8.6p1.tar.gz
cd openssh-8.6p1/
./configure --prefix=/usr/ --sysconfdir=/etc/ssh/ --with-ssl-dir=/usr/local/ssl --with-md5-passwords --mandir=/usr/share/man/
$ echo $?
0
$ make && make install
8、其他
rm -f /etc/ssh/ssh_host_*
$ cp -a contrib/redhat/sshd.init /etc/init.d/sshd
$ vi /etc/init.d/sshd
chkconfig sshd on
chkconfig --list sshd
vi /etc/ssh/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
AllowTcpForwarding yes
X11Forwarding yes
PidFile /run/sshd.pid
vi /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target
[Service]
ExecStart=/usr/sbin/sshd
[Install]
WantedBy=multi-user.target
9、启动ssh
systemctl enable sshd
systemctl status sshd
systemctl restart sshd
systemctl status sshd
10、增加sshd配置信息
$ vim /etc/ssh/sshd_conf
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1
$ systemctl restart sshd
原创
https://www.jianshu.com/p/e75300b7e8be