多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 概述 /etc/ssh 目录下 ``` /etc/ssh/sshd_config:配置文件 /etc/ssh/ssh_host_ecdsa_key:ECDSA 私钥。 /etc/ssh/ssh_host_ecdsa_key.pub:ECDSA 公钥。 /etc/ssh/ssh_host_key:用于 SSH 1 协议版本的 RSA 私钥。 /etc/ssh/ssh_host_key.pub:用于 SSH 1 协议版本的 RSA 公钥。 /etc/ssh/ssh_host_rsa_key:用于 SSH 2 协议版本的 RSA 私钥。 /etc/ssh/ssh_host_rsa_key.pub:用于 SSH 2 协议版本的 RSA 公钥。 /etc/pam.d/sshd:PAM 配置文件。 ``` ## 安装 ``` # Debian $ sudo aptitude install openssh-server # Red Hat $ sudo yum install openssh-server ``` ## 常用指令 ``` # 启动 systemctl start sshd.service # 停止 systemctl stop sshd.service # 重启 systemctl restart sshd.service # 开机启动 systemctl enable sshd.service ``` ## 场景 ### 禁用root账户登录 /etc/ssh/sshd_config ``` PermitRootLogin no ``` 重启 sshd ### 关闭密码登录 启用密钥登录之后,最好关闭服务器的密码登录 /etc/ssh/sshd_config ``` PasswordAuthentication no ``` 重启 sshd ### 修改默认查询证书路径 `vim /etc/ssh/ssh_config` ``` # 可多个 IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/blue_rsa ```