最终更新:

最终更新:

运行 Ubuntu 22.04 作为服务器时,我遇到了 SCP 问题。虽然我可以通过 SSH 毫无问题地进入它,但尝试通过 SCP 传输文件 [从同一网络上的 Windows 10 计算机] 会导致“连接被拒绝”错误。

> scp -vvvv -P 22 "Pokémon Diamond & Pearl Sinnoh Map.jpg" [email protected]:./
Executing: program ssh.exe host 192.168.0.110, user ubuntu, command scp -v -t ./
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug3: Failed to open file:C:/Users/Dark/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 192.168.0.110 is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.0.110 [192.168.0.110] port 22.
debug3: finish_connect - ERROR: async io completed with error: 10061, io:0000020BB6497460
debug1: connect to address 192.168.0.110 port 22: Connection refused
ssh: connect to host 192.168.0.110 port 22: Connection refused
lost connection

我尝试了以下方法:

  • 允许端口 22
$ sudo ufw allow 22 
$ sudo ufw status 
Status: inactive
  • 重置 .bashrc
cp /etc/skel/.bashrc ~/
  • 验证 SSH 守护程序的状态
$ systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2024-01-27 21:36:24 JST; 3s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 28095 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 28096 (sshd)
      Tasks: 1 (limit: 1660)
     Memory: 1.6M
        CPU: 65ms
     CGroup: /system.slice/ssh.service
             └─28096 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Jan 27 21:36:24 ubuntu systemd[1]: Starting OpenBSD Secure Shell server...
Jan 27 21:36:24 ubuntu sshd[28096]: Server listening on 0.0.0.0 port 22.
Jan 27 21:36:24 ubuntu sshd[28096]: Server listening on :: port 22.
Jan 27 21:36:24 ubuntu systemd[1]: Started OpenBSD Secure Shell server.

我的理解是 SCP 通过使用 SSH 作为链接来工作,不是吗?还是我忽略了什么?

Edit:我探索了端口 22 和 8022(基于我在网上找到的信息),但似乎都不起作用。下面是我针对端口 8022 执行的 SCP 命令:

scp -vvvv -P 8022 "Pokémon Diamond & Pearl Sinnoh Map.jpg" [email protected]:./

更新[根据@user68186的要求]:

我通过内部运行ssh和。scpcmdWindows Terminal

> ssh [email protected]
[email protected]'s password:
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-1037-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sat Jan 27 22:58:44 JST 2024

  System load:  0.0068359375       Temperature:            48.7 C
  Usage of /:   58.7% of 28.94GB   Processes:              280
  Memory usage: 47%                Users logged in:        2
  Swap usage:   11%                IPv4 address for wlan0: 192.168.0.110

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

Expanded Security Maintenance for Applications is not enabled.

254 updates can be applied immediately.
175 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

30 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm


Last login: Sat Jan 27 19:29:14 2024 from 192.168.0.102

最终更新:

考虑到花了大量时间解决此SCP传输问题,并且考虑到和SFTPSamba可行的替代方案,我决定改用它们并将时间分配到其他地方。到目前为止,我非常感谢大家的见解和帮助。如果您愿意,请随时继续进一步调查。干杯!

相关内容