在Linux中,使用SFTP(SSH File Transfer Protocol)进行文件共享是一种安全且高效的方式。以下是使用SFTP进行文件共享的步骤:
首先,确保你的Linux系统上安装了OpenSSH服务器。大多数Linux发行版默认已经安装了OpenSSH。
sudo apt update
sudo apt install openssh-server
sudo yum update
sudo yum install openssh-server
sudo dnf update
sudo dnf install openssh-server
确保SSH服务正在运行,并设置为开机自启动。
sudo systemctl start ssh
sudo systemctl enable ssh
sudo systemctl start sshd
sudo systemctl enable sshd
sudo systemctl start sshd
sudo systemctl enable sshd
确保防火墙允许SSH连接。通常,SSH默认端口是22。
sudo ufw allow 22
sudo ufw enable
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
现在,你可以使用SFTP客户端连接到你的Linux服务器并进行文件传输。
打开终端。
输入以下命令连接到服务器:
sftp username@hostname
其中,username
是你的用户名,hostname
是服务器的IP地址或域名。
连接成功后,你会看到一个提示符,类似于:
sftp>
使用以下命令进行文件传输:
put localfile remotefile
get remotefile localfile
ls
cd directory
exit
如果你更喜欢使用图形化界面,可以使用以下流行的SFTP客户端:
这些客户端通常提供直观的用户界面,使得文件传输更加方便。
通过以上步骤,你可以在Linux系统中使用SFTP进行文件共享。确保你的连接是安全的,并且遵循最佳实践来保护你的数据。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:如何利用Linux SFTP进行文件共享