目录
一、xshell使用xftp传输文件
二、使用pure-ftpd搭建ftp服务
一、xshell使用xftp传输文件
- xftp6安装完成后在已打开会话中按ctrl+alt+f打开xftp
- 关闭vsftpd的ftp服务
[root@minglinux-01 ~] systemctl stop vsftpd
[root@minglinux-01 ~] netstat -lntp //21端口不再监听
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 1512/rpc.mountd
tcp 0 0 0.0.0.0:56309 0.0.0.0:* LISTEN 1504/rpc.statd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 782/sshd
tcp 0 0 0.0.0.0:34296 0.0.0.0:* LISTEN -
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::36705 :::* LISTEN 1504/rpc.statd
tcp6 0 0 :::3306 :::* LISTEN 1225/mysqld
tcp6 0 0 :::33900 :::* LISTEN -
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20048 :::* LISTEN 1512/rpc.mountd
tcp6 0 0 :::22 :::* LISTEN 782/sshd
-
桌面与虚拟机的文件相互传输
双击或拖拽
二、使用pure-ftpd搭建ftp服务
pure-ftpd为另外一款比较小巧实用的FTP软件
- 安装pure-ftpd
//pure-ftpd包在epel扩展源中
[root@minglinux-01 ~] yum install -y pure-ftpd
- 配置pure-ftpd
[root@minglinux-01 ~] vim /etc/pure-ftpd/pure-ftpd.conf
## 把PureDB /etc/pure-ftpd/pureftpd.pdb前面的#删除
···
126 PureDB /etc/pure-ftpd/pureftpd.pdb
···
- 启动pure-ftpd
启动pure-ftpd之前需要关闭vsftpd,不然会端口冲突(都用21端口)
[root@minglinux-01 ~] systemctl start pure-ftpd
Job for pure-ftpd.service failed because the control process exited with error code. See "systemctl status pure-ftpd.service" and "journalctl -xe" for details.
[root@minglinux-01 ~] systemctl status pure-ftpd -l
● pure-ftpd.service - Pure-FTPd FTP server
Loaded: loaded (/usr/lib/systemd/system/pure-ftpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 三 2018-12-12 15:15:55 CST; 12s ago
Process: 1642 ExecStart=/usr/sbin/pure-config.pl /etc/pure-ftpd/pure-ftpd.conf --daemonize (code=exited, status=127)
12月 12 15:15:55 minglinux-01 systemd[1]: Starting Pure-FTPd FTP server...
12月 12 15:15:55 minglinux-01 pure-config.pl[1642]: /usr/sbin/pure-ftpd: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
12月 12 15:15:55 minglinux-01 systemd[1]: pure-ftpd.service: control process exited, code=exited status=127
12月 12 15:15:55 minglinux-01 systemd[1]: Failed to start Pure-FTPd FTP server.
12月 12 15:15:55 minglinux-01 systemd[1]: Unit pure-ftpd.service entered failed state.
12月 12 15:15:55 minglinux-01 systemd[1]: pure-ftpd.service failed.
//启动失败,网上查到解决办法是查看你的mysql安装目录下/安装目录/lib/libmysqlclient.so.18是否存在,如果存在,那就做一个软链接到/usr/lib64/目录下
[root@minglinux-01 ~] ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64[root@minglinux-01 ~]
[root@minglinux-01 ~] systemctl start pure-ftpd
[root@minglinux-01 ~] ps aux |grep pure-ftpd //pure-ftpd启动成功
root 1686 0.0 0.0 203400 1288 ? Ss 15:26 0:00 pure-ftpd (SERVER)
root 1693 0.0 0.0 112720 984 pts/0 S+ 15:30 0:00 grep --color=auto pure-ftpd
[root@minglinux-01 ~] netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:40846 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 821/rpc.mountd
tcp 0 0 0.0.0.0:40947 0.0.0.0:* LISTEN 801/rpc.statd
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1686/pure-ftpd (SER
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 799/sshd
tcp6 0 0 :::42593 :::* LISTEN -
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::3306 :::* LISTEN 1287/mysqld
tcp6 0 0 :::57807 :::* LISTEN 801/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20048 :::* LISTEN 821/rpc.mountd
tcp6 0 0 :::21 :::* LISTEN 1686/pure-ftpd (SER
tcp6 0 0 :::22 :::* LISTEN 799/sshd
- 建立相关用户及文件目录
[root@minglinux-01 ~] mkdir /data/ftp
[root@minglinux-01 ~] useradd -u 1020 pure-ftp //创建系统用户pure-ftp,指定uid
[root@minglinux-01 ~] chown -R pure-ftp:pure-ftp /data/ftp //修改目录的属主属组
[root@minglinux-01 ~] pure-pw useradd ftp_usera -u pure-ftp -d /data/ftp
Password:
Enter it again:
[root@minglinux-01 ~] pure-pw mkdb //创建用户信息数据库文件
为了安全,pure-ftpd使用的账号并非Linux的系统账号,而是虚拟账号。pure-pw命令的-u选项将虚拟用户ftp_usera与系统用户pure-ftp关联在一起,也就是说,使用ftp_usera账号登录FTP后,会以pure-ftp的身份来读取和下载文件,-d选项后面的目录为ftp_usera账户的家目录,这样可以使ftp_usera只能访问其家目录/data/ftp/。
- pure-pw命令的用法
[root@minglinux-01 ~] pure-pw --help
Usage :
pure-pw useradd [-f ] -u [-g ]
-D/-d [-c ]
[-t ] [-T ]
[-n ] [-N ]
[-q ] [-Q ]
[-r /] [-R /]
[-i /] [-I /]
[-y ]
[-z -] [-m]
pure-pw usermod -f -u [-g ]
-D/-d -[c ]
[-t ] [-T ]
[-n ] [-N ]
[-q ] [-Q ]
[-r /] [-R /]
[-i /] [-I /]
[-y ]
[-z -] [-m]
pure-pw userdel [-f ] [-m]
pure-pw passwd [-f ] [-m]
pure-pw show [-f ]
pure-pw mkdb [ [-f ]]
[-F ]
pure-pw list [-f ]
-d : chroot user (recommended)
-D : don't chroot user
-
- 测试
[root@minglinux-01 ~] touch /data/ftp/123.txt
[root@minglinux-01 ~] lftp [email protected]
口令:
lftp [email protected]:~> ls
drwxr-xr-x 2 1020 pure-ftp 21 Dec 12 16:43 .
drwxr-xr-x 2 1020 pure-ftp 21 Dec 12 16:43 ..
-rw-r--r-- 1 0 0 0 Dec 12 16:43 123.txt
//修改123.txt文件属主属组
lftp [email protected]:/> quit
[root@minglinux-01 ~] chown pure-ftp:pure-ftp /data/ftp/123.txt
[root@minglinux-01 ~] lftp [email protected]
口令:
lftp [email protected]:~> ls
drwxr-xr-x 2 1020 pure-ftp 21 Dec 12 16:43 .
drwxr-xr-x 2 1020 pure-ftp 21 Dec 12 16:43 ..
-rw-r--r-- 1 1020 pure-ftp 0 Dec 12 16:43 123.txt
扩展
vsftp使用mysql存放虚拟用户并验证 http://www.aminglinux.com/bbs/thread-342-1-1.html
ftp的主动和被动模式 http://www.aminglinux.com/bbs/thread-961-1-1.html