在CentOS系統中,使用SFTP(SSH File Transfer Protocol)進行文件傳輸是一種安全的方式,因為它通過SSH加密數據傳輸。以下是使用SFTP進行文件傳輸的基本步驟:
更新系統包:
sudo yum update -y
安裝OpenSSH服務器:
sudo yum install openssh-server -y
啟動并啟用SSH服務:
sudo systemctl start sshd
sudo systemctl enable sshd
檢查SSH服務狀態:
sudo systemctl status sshd
你可以使用命令行SFTP客戶端或者圖形界面的SFTP客戶端(如FileZilla)來連接服務器。
打開終端。
連接到SFTP服務器:
sftp username@hostname
其中,username
是你的用戶名,hostname
是服務器的IP地址或域名。
登錄: 輸入你的密碼并按回車鍵。
常用SFTP命令:
ls
:列出當前目錄下的文件和文件夾。cd directory
:切換到指定目錄。get remote-file local-file
:從服務器下載文件到本地。put local-file remote-file
:將本地文件上傳到服務器。mkdir directory
:在服務器上創建新目錄。rmdir directory
:刪除服務器上的空目錄。rm file
:刪除服務器上的文件。exit
或 bye
:退出SFTP會話。下載并安裝FileZilla:
sudo yum install filezilla -y
打開FileZilla。
配置連接:
使用FileZilla進行文件傳輸:
通過以上步驟,你可以在CentOS系統上使用SFTP進行安全的文件傳輸。