银河麒麟如何安装ssh
内核版本:5.4.18-85-generic
一、安装ssh
1、安装命令(Ubuntu / Debian )
sudoaptupdate&&sudoaptinstallopenssh-server2、启动与开机自启
sudosystemctlenable--nowssh或者
sudosystemctlenablessh# 开机自启sudosystemctl startssh# 立即启动3、配置文件路径
/etc/ssh/sshd_config4、使用 vim 或 nano 编辑(需要 root 或 sudo 权限)
sudovim/etc/ssh/sshd_config| 配置项 | 推荐值 | 说明 | 配置文件中实际写法 |
|---|---|---|---|
PasswordAuthentication | yes | 必须开启,否则无法用密码登录 | PasswordAuthentication yes |
PubkeyAuthentication | yes | 保持开启,密钥和密码可并存 | PubkeyAuthentication yes |
Port | 22 | SSH 服务监听端口,建议改高端口 | Port 22 |
PermitRootLogin | no | 禁止 root 直接密码登录,更安全 | PermitRootLogin no |
MaxAuthTries | 6 | 最大密码尝试次数,防暴力破解 | MaxAuthTries 6 |
LoginGraceTime | 2m | 登录超时时间,超时自动断开 | LoginGraceTime 2m |
ChallengeResponseAuthentication | no | 禁用挑战响应认证,保持关闭 | ChallengeResponseAuthentication no |
UsePAM | yes | PAM 负责密码验证,必须开启 | UsePAM yes |
5、重新加载配置:
sudosystemctl reloadssh6、检查ssh状态
sudosystemctl statusssh7、临时登录
ssh-oStrictHostKeyChecking=no-oUserKnownHostsFile=NUL kylin@192.xx.xxx