0
点赞
收藏
分享

微信扫一扫

Linux a服务器复制文件到b服务器

惠特曼 03-30 22:30 阅读 2

Linux a服务器复制文件到b服务器

(1) SCP (Secure Copy Protocol):

$ scp /path/to/local/file username@remote_server:/path/to/remote/directory

这将通过 SSH 安全地将文件从本地服务器复制到远程服务器。

描述:

  • /path/to/local/file 替换为本地文件的路径,
  • username 替换为远程服务器的用户名,
  • remote_server 替换为远程服务器的 IP 地址或域名,
  • /path/to/remote/directory 替换为远程服务器上存储文件的目标目录路径。

使用该方法报错:
The authenticity of host ‘121.37.170.205 (121.37.170.205)’ can’t be established. 报错

这个错误是因为你第一次连接到远程服务器,SSH 不确定是否应该信任该主机。你可以通过以下方法解决这个问题:

$ scp -o PasswordAuthentication=yes /usr/local/tomcat/webapps/upload.zip root@121.37.170.205:/usr/local/tomcat/webapps/

在执行 SCP 命令时,可以使用 -o PasswordAuthentication=yes 选项强制使用密码认证,系统会提示你输入远程服务器的密码,确保密码输入正确。

(2)使用 rsync 命令(该方法未测试)

$ rsync -avz /path/to/local/file username@remote_server:/path/to/remote/directory

描述:

  • /path/to/local/file 替换为本地文件的路径,
  • username 替换为远程服务器的用户名,
  • remote_server 替换为远程服务器的 IP 地址或域名,
  • /path/to/remote/directory 替换为远程服务器上存储文件的目标目录路径。
举报

相关推荐

0 条评论