Linux通过ssh命令远程登录后本地文件怎么上传到Linux和下载到本地
时间: 2024-02-12 12:11:48 浏览: 137
在Linux通过ssh命令远程登录后,可以使用scp命令来实现本地文件上传和下载。
上传本地文件到Linux:
```
scp /path/to/local/file username@remote:/path/to/remote/directory
```
其中,/path/to/local/file是本地文件路径,username是远程服务器的用户名,remote是远程服务器的IP地址或主机名,/path/to/remote/directory是远程服务器的目标目录路径。
例如,要将本地文件/home/user/test.txt上传到远程服务器192.168.1.100的/home/remote目录下,可以使用以下命令:
```
scp /home/user/test.txt username@192.168.1.100:/home/remote/
```
下载远程文件到本地:
```
scp username@remote:/path/to/remote/file /path/to/local/directory
```
其中,/path/to/remote/file是远程服务器的文件路径,/path/to/local/directory是本地目标目录路径。
例如,要将远程服务器192.168.1.100的/home/remote/test.txt文件下载到本地/home/user目录下,可以使用以下命令:
```
scp username@192.168.1.100:/home/remote/test.txt /home/user/
```
注意,在使用scp命令时,需要先通过ssh命令登录到远程服务器,确保本地和远程服务器之间已经建立起了安全的加密连接。
阅读全文
相关推荐












