简体   繁体   English

在远程服务器 linux 上复制/移动文件

[英]copy/move files on remote server linux

I log into server_a and run .sh file, which has the following script:我登录到server_a并运行.sh文件,其中包含以下脚本:

scp user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/

to copy files from my_folder to my_new_folder at server_b .从复制文件my_foldermy_new_folderserver_b It doesn't throw an error, but no files are copied.它不会引发错误,但不会复制任何文件。

Notes:笔记:

  • server_b is accessed by the pre-set rsa_keys. server_b由预设的 rsa_keys 访问。
  • server_a : unix server_a : Unix
  • server_b : ubuntu server_b : ubuntu
  • can SCP files from/to these servers without any issues可以从/向这些服务器发送 SCP 文件而不会出现任何问题

The end goal is to move or copy/remove files.最终目标是移动或复制/删除文件。

There are two possibilities:有两种可能:

  1. Connect from server_a to server_b and do local copy:server_a连接到server_b并进行本地复制:

     ssh user@server_b "cp /my_folder/my_file.xml /my_new_folder/"
  2. Do copy over the server_a .复制server_a Your method would require the server_b to be able to authenticate to itself, which is probably not the case:您的方法需要server_b能够对其自身进行身份验证,这可能不是这种情况:

     scp -3 user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/

Also note that your code copies only one file and not files as you write in the title.另请注意,您的代码仅复制一个文件,而不是您在标题中写入的文件。

If you are logged on to the server, why are you authenticating again:如果您登录到服务器,为什么要再次进行身份验证:

scp user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/

You should be in the directory of file or simply use scp and use -v parameter to see the debug information.您应该在文件目录中或简单地使用 scp 并使用-v参数来查看调试信息。

Run as follows:运行如下:

scp -v /my_folder/my_file.xml user@server_b:/my_new_folder/

It is not a directory nor it is recursive, so you do not need to -r parameter.它不是目录,也不是递归的,因此您不需要-r参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM