说目标机器是user@B.com,唯一的登录位置是user@A.com(通常称为跳跃机)
以及如何使用scp命令将本地文件复制到机器 B
我已经尝试过scp files user@B.com,但是什么也没有发生,它只是告诉我某种操作超时

请您参考如下方法:

我不确定这是否是最佳解决方案,但是您可以使用ssh中包含的tcp端口转发功能。

首先,请确保跳台计算机对sshd_config文件具有“Tcp转发”启用功能,该文件通常位于目录“/ etc / ssh /”中。
检查您是否输入:

AllowTcpForwarding no



默认情况下,TcpForwarding是启用的,因此,如果未禁用它,则可以确定。

您将在跳跃机器上建立连接,并在系统上本地创建一个端口fording端口以直接与系统B通信

在您的工作站上运行的ssh命令将是:
ssh -L 2222:server_B:22 server_A 

从ssh手册页:

-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and a connection is made to host port hostport from the remote machine



因此,要从您的工作站将文件发送到服务器B:
scp -P 2222 Your_file 127.0.0.1:/PATH_ON_SERVER_B 

祝你今天愉快。


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!