今天想用winscp传输文件但突然连接不上了,问题排查如下:

1、是否为密码修改导致?

(1)直接修改用户名密码,登陆后,超时。

(2)将站点删除增加新站点,输入IP用户名及密码登陆,超时。

2、是否为防火墙问题导致?

(1)查看目前防火墙状态,为activing:

systemctl status firewalld

systemctl stop firewalld

(2)关闭后发现winscp仍然连接超时,所以目前看不是防火墙问题,安全起见继续启用防火墙。

systemctl restart firewalld

3、是否为ssh或端口导致?

(1)查看22端口状态,有我的ip且端口22号正常使用,因为直接筛查的sshd,说明服务也正常启用。

[root@localhost ~]# netstat -antp | grep sshd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      18749/sshd          
tcp        0      0 ip:22                   ip:38592     ESTABLISHED 19395/sshd: root@pt 
tcp6       0      0 :::22                   :::*                    LISTEN      18749/sshd          
[root@localhost ~]# 

(2)如果sshd没有启用,就安装然后启动。

默认端口22,可以到/etc/ssh/sshd_config看,修改配置项参数等等。

安装:yum install ssh

启动:

(1)service sshd start(我用这个指令就报Redirecting to /bin/systemctl restart sshd.service,直接用(2)指令的话就没有报了。)

(2)systemctl start sshd.service

重启/停止/状态查询:

(1)service sshd restart/stop/status(我用这个指令就报Redirecting to /bin/systemctl restart sshd.service,直接用(2)指令的话就没有报了。)

(2)systemctl restart/stop/status sshd.service

[root@localhost /]# service sshd status
Redirecting to /bin/systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since 四 2022-02-17 14:25:04 CST; 56s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 20051 (sshd)
   CGroup: /system.slice/sshd.service
           └─20051 /usr/sbin/sshd -D

2月 17 14:25:04 localhost.uino.local systemd[1]: Starting OpenSSH server daemon...
2月 17 14:25:04 localhost.uino.local sshd[20051]: Server listening on 0.0.0.0 port 22.
2月 17 14:25:04 localhost.uino.local sshd[20051]: Server listening on :: port 22.
2月 17 14:25:04 localhost.uino.local systemd[1]: Started OpenSSH server daemon.
[root@localhost /]# service sshd stop
Redirecting to /bin/systemctl stop sshd.service
[root@localhost /]# service sshd status
Redirecting to /bin/systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 四 2022-02-17 14:26:08 CST; 14s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 20051 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 20051 (code=exited, status=0/SUCCESS)

2月 17 14:25:04 localhost.uino.local systemd[1]: Starting OpenSSH server daemon...
2月 17 14:25:04 localhost.uino.local sshd[20051]: Server listening on 0.0.0.0 port 22.
2月 17 14:25:04 localhost.uino.local sshd[20051]: Server listening on :: port 22.
2月 17 14:25:04 localhost.uino.local systemd[1]: Started OpenSSH server daemon.
2月 17 14:26:08 localhost.uino.local systemd[1]: Stopping OpenSSH server daemon...
2月 17 14:26:08 localhost.uino.local sshd[20051]: Received signal 15; terminating.
2月 17 14:26:08 localhost.uino.local systemd[1]: Stopped OpenSSH server daemon.
[root@localhost /]# service sshd restart
Redirecting to /bin/systemctl restart sshd.service
[root@localhost /]# service sshd status
Redirecting to /bin/systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since 四 2022-02-17 14:26:37 CST; 3s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 20109 (sshd)
   CGroup: /system.slice/sshd.service
           └─20109 /usr/sbin/sshd -D

2月 17 14:26:37 localhost.uino.local systemd[1]: Starting OpenSSH server daemon...
2月 17 14:26:37 localhost.uino.local sshd[20109]: Server listening on 0.0.0.0 port 22.
2月 17 14:26:37 localhost.uino.local sshd[20109]: Server listening on :: port 22.
2月 17 14:26:37 localhost.uino.local systemd[1]: Started OpenSSH server daemon.

4、我想到了一点而且解决了winscp连接问题,因为我没有连接公司的VPN所以一直连接不上!!!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐