freeCodeCamp/guide/chinese/linux/how-to-use-sftp-to-securely.../index.md

64 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: How to Use SFTP to Securely Transfer Files with a Remote Server
localeTitle: 如何使用SFTP通过远程服务器安全地传输文件
---
## 如何使用SFTP通过远程服务器安全地传输文件
本文是关于如何使用安全文件传输协议SFTP与服务器交换文件的快速教程。这对编程很有用因为它允许您在本地编码和测试然后在完成后将您的工作发送到服务器。
### 测试SSH
如果您还没有请测试您是否能够SSH到服务器。 SFTP使用Secure ShellSSH协议因此如果您无法通过SSH您可能也无法使用SFTP。
```unix
ssh your_username@hostname_or_ip_address
```
### 启动SFTP会话
它使用与SSH相同的语法并打开一个可以传输文件的会话。
```unix
sftp your_username@hostname_or_ip_address
```
要列出有用的命令:
```unix
help
```
### 传输文件和文件夹
要下载文件:
```unix
get <filename>
```
要下载文件夹及其内容,请使用“-r”标志也可用于上载
```unix
get -r <foldername>
```
要上传文件:
```unix
put <filename>
```
### 更改文件夹
要更改本地文件夹:
```unix
lcd <path/to/folder>
```
要更改远程文件夹:
```unix
cd <path/to/folder>
```