作者:pyg2358_586 | 来源:互联网 | 2023-06-18 23:46
先安装telnet,以防安装ssh出现问题,无法远程登录设备。最新版openssh下载地址:http:www.openssh.comftp.html一、安装telnet和xinet
先安装telnet,以防安装ssh出现问题,无法远程登录设备。
最新版openssh下载地址:http://www.openssh.com/ftp.html
一、安装telnet和xinetd:
1、安装telnet和xinetd
systemctl stop firewalld #安装完不要忘了开启防火墙
rpm -qa | grep telnet
yum -y install telnet telnet-server
systemctl enable telnet.socket
systemctl start telnet.socket
rpm -qa | grep xinetd
yum -y install xinetd
systemctl enable xinetd.service
systemctl start xinetd
2、连接测试:(远程连接)
telnet ip地址
二、安装openssh7.9p1:
1、卸载旧版本:
rpm -qa | grep openssh|xargs rpm -e --nodeps
2、解压编译安装:
#下载
wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
#解压编译(存在报错的话,参见“三、编译安装报错集合”)
tar -zxf openssh-7.9p1.tar.gz
cd openssh-7.9p1
./configure --prefix=/usr --syscOnfdir=/etc/ssh
make && make install
3、修改配置:
vim /etc/ssh/sshd_config
PermitRootLogin no
4、添加服务/启动服务:
cp openssh-7.9p1/contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig --add sshd
systemctl daemon-reload
systemctl start sshd
5、检查版本信息:
# ssh -V
OpenSSH_7.9p1, OpenSSL 1.0.2k-fips 26 Jan 2017
6、卸载telnet:
rpm -qa | grep telnet |xargs rpm -e --nodeps
三、编译安装报错集合:
1、./configure --prefix=/usr --syscOnfdir=/etc/ssh 报错汇总
【报错1】
configure: error: *** zlib.h missing - please install first or check config.log ***
解决方法:
# yum install -y zlib-devel
【报错2】
configure: error: *** OpenSSL headers missing - please install firstorcheck config.log
或者
configure: error: *** OpenSSL headers missing - please install first or check config.log ***
解决方法:
# yum -y install openssl-devel
2、make install报错:
【报错】
ssh-keygen: generating new host keys: DSA
/usr/sbin/sshd -t -f /etc/ssh/sshd_config
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Error loading host key "/etc/ssh/ssh_host_rsa_key": bad permissions
Could not load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Error loading host key "/etc/ssh/ssh_host_ecdsa_key": bad permissions
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Error loading host key "/etc/ssh/ssh_host_ed25519_key": bad permissions
Could not load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.
make: [check-config] Error 1 (ignored)
解决方法:
# rm -rf /etc/ssh/ssh_host_*
# make install
参照:
https://www.cnblogs.com/lixuwu/p/6102444.html
https://blog.csdn.net/qq_38693296/article/details/85698554