在Alpine Linux上设置SSH远程访问的步骤如下:
apk add openssh
vi /etc/ssh/sshd_config
找到以下行并取消注释:
#Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #PermitRootLogin prohibit-password #PubkeyAuthentication yes #PasswordAuthentication yes #ChallengeResponseAuthentication no #UsePAM yes 确保以下设置已启用:
Port:ssh服务监听的端口号。默认为22。
PermitRootLogin:是否允许root用户通过ssh登录。建议将其设置为no以提高安全性。
PubkeyAuthentication:是否启用公钥验证身份。建议启用以提高安全性。
PasswordAuthentication:是否启用密码验证身份。建议禁用以提高安全性。
UsePAM:是否启用PAM身份验证。
/etc/init.d/sshd start
ps -ef | grep sshd
如果您使用的是防火墙,请确保已经打开ssh端口(默认为22):
ufw allow ssh