scp

发布时间 2023-12-07 15:16:06作者: 爱新觉罗玄烨

scp

网络间cp

命令

从本地计算机复制文件到远程计算机:
scp /path/to/local/file.txt remoteuser@remotehost:/path/to/remote/location/
复制代码
scp /path/to/local/file.txt remoteuser@remotehost:/path/to/remote/location/

这个命令将本地计算机上的file.txt文件复制到远程计算机remotehost中/path/to/remote/location/目录下。

从远程计算机复制文件到本地计算机:
scp remoteuser@remotehost:/path/to/remote/file.txt /path/to/local/destination/
复制代码
scp remoteuser@remotehost:/path/to/remote/file.txt /path/to/local/destination/

这个命令将远程计算机remotehost上的file.txt文件复制到本地计算机的/path/to/local/destination/目录中。

传输整个目录:
scp -r /path/to/local/directory/ remoteuser@remotehost:/path/to/remote/location/
复制代码
scp -r /path/to/local/directory/ remoteuser@remotehost:/path/to/remote/location/

这个命令将本地计算机上的directory目录及其所有文件和子目录复制到远程计算机remotehost中/path/to/remote/location/目录下。

请确保正确设置了正确的路径和用户名以及目标位置,并提供正确的远程计算机的密码或SSH密钥以完成SCP文件传输。