【问题标题】:Copy file to server with specific port using scp in Linux [closed]在Linux中使用scp将文件复制到具有特定端口的服务器[关闭]
【发布时间】:2015-04-22 08:26:23
【问题描述】:

如果我想将文件从服务器复制到本地操作系统,我使用这个:

scp -P 60385 root@162.243.120.200:/myserver/somefile.txt /mylocaladdress/.

但是我该如何做相反的事情呢?

我试过这个:

scp /mylocaladdress/somefile.txt root@162.243.120.200:/myserver/. -P 60835

还有这个:

scp /mylocaladdress/somefile.txt -P 60835 root@162.243.120.200:/myserver/. 

但是我收到了这个错误

ssh: connect to host 162.243.120.200 port 22: Connection refused
lost connection

我在本地有Ubuntu,在服务器上有CentOS 6.5

【问题讨论】:

  • scp -P 24 local_file user@server:/path/ 工作正常。 man scp show---> scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user @]host1:]file1 ... [[user@]host2:]file2
  • 除了 scp,你可以在服务器 nc -l 2001 上使用 nc - netcat - /tmp/file.txt。或者如果您想递归地执行此操作 tar -cvzf - 文件夹 | nc -l 2001 在主机和从机上 nc master 2001 |tar -xvzf -

标签: linux centos port scp


【解决方案1】:

man scp 显示:

      scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

端口在文件和主机之前

【讨论】:

  • 是的,你是对的。谢谢
猜你喜欢
  • 2015-11-12
  • 2016-04-18
  • 2019-11-07
  • 2012-02-17
  • 2013-05-14
  • 2016-02-08
  • 2016-03-27
  • 2020-01-19
  • 2019-08-15
相关资源
最近更新 更多