liunx开启ssh
[TOC]
开启并查看SSH是否开启
systemctl start ssh
systemctl status ssh
修改配置文件
vim /etc/ssh/sshd_config
#PasswordAuthentication yes(去掉注释)
#PermitRootLogin prohibit-password(去掉注释,将prohibit-password删除并改为yes)
重启ssh 服务
systemctl restart ssh
配置文件参数说明
Port 设置sshd监听的端口号。
ListenAddress 0.0.0.0 “ListenAddress”设置sshd服务器绑定的IP地址。
HostKey /etc/ssh/ssh_host_key “HostKey”设置包含计算机私人密匙的文件。
LoginGraceTime 2m
“LoginGraceTime”设置如果用户不能成功登录,在切断连接之前服务器需要等待的时间(以秒为单位)。
PermitRootLogin prohibit-password
表示允许 root 账户登录,但是不能以密码的方式登录,所以只能以公私钥的方式登录,为了简便,我们不采用这种方式,而是采用 PermitRootLogin yes,这样,直接使用密码就可以登录了。
IgnoreRhosts yes
“IgnoreRhosts”设置验证的时候是否使用“rhosts”和“shosts”文件。
IgnoreUserKnownHosts yes
“IgnoreUserKnownHosts”设置ssh daemon是否在进行RhostsRSAAuthentication安全验证的时候忽略用户的“$HOME/.ssh/known_hosts”
StrictModes yes
“StrictModes”设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权。这通常是必要的,因为新手经常会把自己的目录和文件设成任何人都有写权限。
X11Forwarding no
“X11Forwarding”设置是否允许X11转发。
PrintMotd yes
“PrintMotd”设置sshd是否在用户登录的时候显示“/etc/motd”中的信息。
SyslogFacility AUTH
“SyslogFacility”设置在记录来自sshd的消息的时候,是否给出“facility code”。
LogLevel INFO
“LogLevel”设置记录sshd日志消息的层次。INFO是一个好的选择。查看sshd的man帮助页,已获取更多的信息。
RhostsAuthentication no
“RhostsAuthentication”设置只用rhosts或“/etc/hosts.equiv”进行安全验证是否已经足够了。
RhostsRSAAuthentication no
“RhostsRSA”设置是否允许用rhosts或“/etc/hosts.equiv”加上RSA进行安全验证。
RSAAuthentication yes
“RSAAuthentication”设置是否允许只有RSA安全验证。
PasswordAuthentication yes
“PasswordAuthentication”设置是否允许口令验证。
PermitEmptyPasswords no
“PermitEmptyPasswords”设置是否允许用口令为空的帐号登录。
本文首发于 CSDN:liunx开启ssh
[COMMENTS]