在CentOS上安装OpenSSH时可能会遇到各种错误
sudo yum install epel-release
sudo yum groupinstall "Development Tools"
sudo yum install openssl-devel zlib-devel
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz
请注意,上述链接中的版本号可能已过时。请访问OpenSSH官方网站以获取最新版本。
tar xvf openssh-8.4p1.tar.gz
cd openssh-8.4p1
./configure --prefix=/usr/local/ssh --with-openssh-sftp-server --with-pam --with-libssl-prefix=/usr/local/ssl
make
sudo make install
/usr/local/ssh/sshd_config
的文件,并使用以下内容填充它:# System specific configuration file for OpenSSH server.
# See sshd_config(5) for details.
# The following values are recommended for security:
# Use Kerberos authentication.
# KRB5CCNAME=/tmp/krb5cc_uid
# Use hostkey authentication.
# HostkeyAlgorithms +ssh-rsa +ssh-dss +ssh-ed25519
# PermitRootLogin prohibit-password
# PasswordAuthentication yes
# PermitEmptyPasswords no
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PubkeyAuthentication yes
# AuthorizedKeysFile .ssh/authorized_keys
# PasswordAuthentication yes
# ChallengeResponseAuthentication yes
# UsePAM yes
# Logging configuration
# LogFormat %h %l %u %t "%r" %s %b
#忍受日志文件的最大大小
# ClientAliveInterval 120
# ClientAliveCountMax 3
# UseDNS no
# DNSCacheTimeout 604800
# AddressFamily any
# ListenAddress 0.0.0.0
# ListenPort 22
# PermitTunnel no
# PermitOpen any
# RhostsNotAllowed no
接下来,创建一个名为/usr/local/ssh/ssh_service
的文件,并使用以下内容填充它:
#!/bin/sh
# /usr/local/ssh/ssh_service
# Start the OpenSSH daemon.
/usr/local/ssl/sbin/sshd -f /usr/local/ssh/sshd_config
确保将/usr/local/ssl
替换为实际的OpenSSL安装路径。
sudo chmod +x /usr/local/ssh/ssh_service
/etc/init.d/sshd
的符号链接,指向刚刚创建的ssh_service
文件:sudo ln -s /usr/local/ssh/ssh_service /etc/init.d/sshd
sudo service sshd start
sudo chkconfig sshd on
现在,您应该已经成功在CentOS上安装了OpenSSH。如果仍然遇到问题,请提供详细的错误信息,以便我们为您提供更具体的解决方案。