在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。如果仍然遇到問題,請提供詳細的錯誤信息,以便我們為您提供更具體的解決方案。