CentOS 7.5 开启 SSH连接
第一步
#查看本机是否安装SSH软件包
1 2 3 4 5 6 |
[root@localhost ~]# rpm -qa | grep ssh openssh-server-7.4p1-16.el7_1.x86_64 openssh-clients-7.4p1-16.el7_1.x86_64 libssh2-1.4.3-10.el7.x86_64 openssh-6.6.1p1-16.el7_1.x86_64 |
#如果没有,则需要安装
1 |
yum install openssh-server |
第二步
#用Vi编辑器修改
1 |
[root@localhost ~]# vi /etc/ssh/sshd_config |
vi 进入文本,按“i”开始编辑,编辑好之后按“esc”退到命令模式,按“:wq”保存 并退出
1 2 3 4 5 6 |
//找到以下几行,把前面的#去掉 Port 22 ListenAddress 0.0.0.0 ListenAddress :: PermitRootLogin yes PasswordAuthentication yes |
第三步
开启 SSH 服务
1 2 |
[root@localhost ~]# service sshd start Redirecting to /bin/systemctl start sshd.service |
#查看TCP 22端口是否打开
1 2 3 |
[root@localhost ~]# netstat -ntpl | grep 22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2048/sshd tcp6 0 0 :::22 :::* LISTEN 2048/sshd |
第四步
#接下来便可使用终端仿真程序(例如putty)去登陆远程主机
如果你在客户端不能连接SSH服务的话,那可能是防火墙的原因,终端命令行中输入 iptables -nL 来看是否开放了ssh tcp 22 端口:
1 |
[root@localhost ~]# iptables -nL |
你可以将防火墙中的规则条目清除掉:
1 |
[root@localhost ~]# iptables -F |
如果觉得我的文章对您有用,望各位有钱的捧钱场,没钱的捧人场啦!先谢过了。
打赏多少无所谓,1元不嫌少,10元不嫌多,都是一份心意。
真诚赞赏,手留余香。

本文未经允许不能转载,如需转载请注明出处 https://www.scit028.com/post-16.html