1、检查服务器是否安装openssh-server,在终端中输入:
yum list installed | grep openssh-server
如果没任何输出显示表示没有安装 openssh-server,通过输入:
yum install openssh-server
2、 找到/etc/ssh/目录下的sshd服务配置文件sshd_config,用vi编辑器打开,将文件中,关于监听端口、监听地址前的 # 号去除
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
#AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
然后开启允许远程登录
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
最后,开启使用用户名密码来作为连接验证
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes
保存文件,退出。
3、开启sshd服务,输入:
sudo service sshd restart
4、检查sshd服务是否已经开启,输入:
ps -e | grep sshd