[英]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_folder
到my_new_folder
在server_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
: Unixserver_b
: ubuntu server_b
: ubuntuThe end goal is to move or copy/remove files.最终目标是移动或复制/删除文件。
There are two possibilities:有两种可能:
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/"
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.