我有一个在 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/