共计 795 个字符,预计需要花费 2 分钟才能阅读完成。
第一步
# 查看本机是否安装 SSH 软件包
[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
# 如果没有,则需要安装
yum install openssh-server
第二步
# 用 Vi 编辑器修改
[root@localhost ~]# vi /etc/ssh/sshd_config
vi 进入文本,按“i”开始编辑,编辑好之后按“esc”退到命令模式,按“:wq”保存 并退出
// 找到以下几行,把前面的 #去掉
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
PermitRootLogin yes
PasswordAuthentication yes
第三步
开启 SSH 服务
[root@localhost ~]# service sshd start
Redirecting to /bin/systemctl start sshd.service
# 查看 TCP 22 端口是否打开
[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 端口:
[root@localhost ~]# iptables -nL
你可以将防火墙中的规则条目清除掉:
[root@localhost ~]# iptables -F
打赏小哥
微信打赏
支付宝打赏
正文完