linux - 在 VM 上使用 scp 时获取连接被拒绝错误

标签 linux ssh scp

我有一个在 qemu 上运行的虚拟 linux 构建(它作为 ssh 客户端运行 drop bear。)我正在尝试使用以下命令复制我使用 scp 写入的一些模块:

    scp -vvv -p 2222 wd/day10/int_mod.ko root@localhost:/lib/modules/3.13.5/int_mod.ko

我更具体地得到连接被拒绝的错误(我将 2222 转发到虚拟机的 22。):

Executing: program /usr/bin/ssh host localhost, user root, command scp -v -p -d -t /lib/modules/3.13.5/int_mod.ko
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host localhost port 22: Connection refused
lost connection

我不明白的是我可以使用

轻松连接到 ssh
   ssh -p 2222 root@localhost

我可以毫无问题地连接。

最佳答案

ssh 和 scp 使用不同的选项来指定端口。来自 ssh 手册页:

[-p port]

来自 scp 手册页:

[-P port]

scp 使用大写字母 P。请注意当您尝试连接到端口 2222 时调试输出如何显示端口 22 连接被拒绝。

关于linux - 在 VM 上使用 scp 时获取连接被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24705374/

相关文章:

java - 我可以使用 Jsch 来伪造与本地主机的 ssh 连接吗?

git - ssh key 在一段时间后停止运行

ant - SCP/SSHEXEC - 连接尝试次数

linux - scp 失败 : Unauthorized access is prohibited

python - 向 usb GSM 调制解调器发送 'AT' 命令在 Python 中返回空字符串

c - 如何在文件描述符上创建选择 block

git - 以无密码用户身份执行命令

c++ - 同一段代码,在 Windows 和 Linux 上的不同行为

Linux - 仅打印目录和子目录的文件名

ssh - 从 windows 到 centos 的安全、预定传输