需要对 OpenSSH 服务器和客户端进行相应配置。以下是具体步骤:
打开 sshd_config 文件:
sudo nano /etc/ssh/sshd_config
找到或添加 Ciphers 选项,并设置需要的加密算法。例如:
Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
找到或添加 MACs 选项,并设置需要的消息认证码算法。例如:
MACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512
找到或添加 KexAlgorithms 选项,并设置需要的密钥交换算法。例如:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
sudo systemctl restart sshd
打开 ssh_config 文件:
sudo nano /etc/ssh/ssh_config
或者编辑用户级别的配置文件:
nano ~/.ssh/config
在文件中添加或修改 Ciphers 选项。例如:
Host *
Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
添加或修改 MACs 选项。例如:
Host *
MACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512
添加或修改 KexAlgorithms 选项。例如:
Host *
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
通过上述步骤,你可以在 OpenSSH 服务器和客户端中配置所需的加密算法、消息认证码算法和密钥交换算法,从而增强 SSH 连接的安全性。根据实际需求选择合适的算法,以平衡安全性和性能。