目录
一、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 <login> [-f <passwd file>] -u <uid> [-g <gid>]
-D/-d <home directory> [-c <gecos>]
[-t <download bandwidth>] [-T <upload bandwidth>]
[-n <max number of files>] [-N <max Mbytes>]
[-q <upload ratio>] [-Q <download ratio>]
[-r <allow client ip>/<mask>] [-R <deny client ip>/<mask>]
[-i <allow local ip>/<mask>] [-I <deny local ip>/<mask>]
[-y <max number of concurrent sessions>]
[-z <hhmm>-<hhmm>] [-m]
pure-pw usermod <login> -f <passwd file> -u <uid> [-g <gid>]
-D/-d <home directory> -[c <gecos>]
[-t <download bandwidth>] [-T <upload bandwidth>]
[-n <max number of files>] [-N <max Mbytes>]
[-q <upload ratio>] [-Q <download ratio>]
[-r <allow client ip>/<mask>] [-R <deny client ip>/<mask>]
[-i <allow local ip>/<mask>] [-I <deny local ip>/<mask>]
[-y <max number of concurrent sessions>]
[-z <hhmm>-<hhmm>] [-m]
pure-pw userdel <login> [-f <passwd file>] [-m]
pure-pw passwd <login> [-f <passwd file>] [-m]
pure-pw show <login> [-f <passwd file>]
pure-pw mkdb [<puredb database file> [-f <passwd file>]]
[-F <puredb file>]
pure-pw list [-f <passwd file>]
-d <home directory> : chroot user (recommended)
-D <home directory> : don't chroot user
-<option> '' : set this option to unlimited
-m : also update the /etc/pure-ftpd/pureftpd.pdb database
For a 1:10 ratio, use -q 1 -Q 10
To allow access only between 9 am and 6 pm, use -z 0900-1800
- 测试
[root@minglinux-01 ~] touch /data/ftp/123.txt
[root@minglinux-01 ~] lftp ftp_usera@127.0.0.1
口令:
lftp ftp_usera@127.0.0.1:~> 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 ftp_usera@127.0.0.1:/> quit
[root@minglinux-01 ~] chown pure-ftp:pure-ftp /data/ftp/123.txt
[root@minglinux-01 ~] lftp ftp_usera@127.0.0.1
口令:
lftp ftp_usera@127.0.0.1:~> 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