/tmp/ 192.168.133.0/24(rw,sync,no_root_squash)
[root@hf-01 ~]# umount /mnt/ [root@hf-01 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 18G 6.5G 12G 37% / devtmpfs 483M 0 483M 0% /dev tmpfs 493M 0 493M 0% /dev/shm tmpfs 493M 6.7M 486M 2% /run tmpfs 493M 0 493M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 99M 0 99M 0% /run/user/0 [root@hf-01 ~]#
[root@hanfeng ~]# exportfs -arv exporting 192.168.202.0/24:/home/nfstestdir [root@hanfeng ~]#
[root@hanfeng ~]# vim /etc/exports 在配置文件中加入 /tmp 192.168.202.131(rw,sync,no_root_squash) 結果以下 /home/nfstestdir 192.168.202.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000) /tmp 192.168.202.131(rw,sync,no_root_squash) 保存退出
[root@hanfeng ~]# exportfs -arv exporting 192.168.202.131:/tmp exporting 192.168.202.0/24:/home/nfstestdir [root@hanfeng ~]#
[root@hf-01 ~]# showmount -e 192.168.202.130 Export list for 192.168.202.130: /home/nfstestdir 192.168.202.0/24 /tmp 192.168.202.131 [root@hf-01 ~]#
[root@hf-01 ~]# mount -t nfs 192.168.202.130:/tmp/ /mnt/ [root@hf-01 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 18G 6.5G 12G 37% / devtmpfs 483M 0 483M 0% /dev tmpfs 493M 0 493M 0% /dev/shm tmpfs 493M 6.7M 486M 2% /run tmpfs 493M 0 493M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 99M 0 99M 0% /run/user/0 192.168.202.130:/tmp 18G 3.2G 15G 18% /mnt [root@hf-01 ~]#
[root@hf-01 ~]# ls /mnt/ hanfeng.sock mysql.sock php-fcgi.sock test.com.log [root@hf-01 ~]#
[root@hanfeng ~]# ls /tmp/ hanfeng.sock mysql.sock php-fcgi.sock test.com.log [root@hanfeng ~]#
[root@hf-01 ~]# vim /mnt/1212.txt [root@hf-01 ~]# ls -l /mnt/ 總用量 8 -rw-r--r-- 1 root root 12 1月 17 2018 1212.txt srw-rw-rw- 1 root root 0 1月 17 2018 hanfeng.sock srwxrwxrwx 1 mysql mysql 0 1月 17 2018 mysql.sock srw-rw-rw- 1 root root 0 1月 17 2018 php-fcgi.sock -rw-r--r-- 1 root root 2383 1月 8 19:41 test.com.log [root@hf-01 ~]#
[root@hanfeng ~]# ls -l /tmp/ 總用量 8 -rw-r--r--. 1 root root 12 1月 17 21:53 1212.txt srw-rw-rw-. 1 root root 0 1月 17 18:44 hanfeng.sock srwxrwxrwx. 1 mysql mysql 0 1月 17 18:44 mysql.sock srw-rw-rw-. 1 root root 0 1月 17 18:44 php-fcgi.sock -rw-r--r--. 1 root root 2383 1月 8 19:41 test.com.log [root@hanfeng ~]#
testuser1 aminglinux
local_root=/home/virftp/testuser1 anonymous_enable=NO write_enable=YES local_umask=022 anon_upload_enable=NO anon_mkdir_write_enable=NO idle_session_timeout=600 data_connection_timeout=120 max_clients=10
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
chroot_local_user=YES guest_enable=YES guest_username=virftp virtual_use_local_privs=YES user_config_dir=/etc/vsftpd/vsftpd_user_conf allow_writeable_chroot=YES
[root@hf-01 ~]# yum install -y vsftpd
[root@hf-01 ~]# useradd -s /sbin/nologin virftp [root@hf-01 ~]#
[root@hf-01 ~]# vim /etc/vsftpd/vsftpd_login 1,3行爲用戶名 2,4行爲密碼 testuser1 hanfeng user1 aaaaa1111 保存退出
[root@hf-01 ~]# chmod 600 /etc/vsftpd/vsftpd_login [root@hf-01 ~]#
[root@hf-01 ~]# db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db [root@hf-01 ~]# ls -l /etc/vsftpd/ 總用量 36 -rw------- 1 root root 125 8月 3 14:10 ftpusers -rw------- 1 root root 361 8月 3 14:10 user_list -rw------- 1 root root 5030 8月 3 14:10 vsftpd.conf -rwxr--r-- 1 root root 338 8月 3 14:10 vsftpd_conf_migrate.sh -rw------- 1 root root 34 1月 18 06:02 vsftpd_login -rw-r--r-- 1 root root 12288 1月 18 06:06 vsftpd_login.db [root@hf-01 ~]#
[root@hf-01 ~]# mkdir /etc/vsftpd/vsftpd_user_conf [root@hf-01 ~]#
[root@hf-01 ~]# cd /etc/vsftpd/vsftpd_user_conf [root@hf-01 vsftpd_user_conf]#
配置文件內容 local_root=/home/virftp/testuser1 //指定虛擬用戶的家目錄 anonymous_enable=NO //是否容許匿名用戶 write_enable=YES //是否可寫 local_umask=022 //建立新文件目錄的默認權限 anon_upload_enable=NO //是否容許匿名用戶上傳 anon_mkdir_write_enable=NO //是否容許匿名用戶建立目錄和寫 idle_session_timeout=600 //鏈接ftp超時時間(秒) data_connection_timeout=120 //數據傳輸的超時時間(秒) max_clients=10 //最多容許同時幾個終端鏈接
[root@hf-01 vsftpd_user_conf]# vim testuser1 local_root=/home/virftp/testuser1 anonymous_enable=NO write_enable=YES local_umask=022 anon_upload_enable=NO anon_mkdir_write_enable=NO idle_session_timeout=600 data_connection_timeout=120 max_clients=10 保存退出
[root@hf-01 vsftpd_user_conf]# mkdir /home/virftp/testuser1 [root@hf-01 vsftpd_user_conf]#
[root@hf-01 vsftpd_user_conf]# touch /home/virftp/testuser1/aming.txt [root@hf-01 vsftpd_user_conf]#
[root@hf-01 vsftpd_user_conf]# chown -R virftp:virftp /home/virftp [root@hf-01 vsftpd_user_conf]#
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
最終以下php
[root@hf-01 vsftpd_user_conf]# vim /etc/pam.d/vsftpd #%PAM-1.0 auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login session optional pam_keyinit.so force revoke auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed auth required pam_shells.so auth include password-auth account include password-auth session required pam_loginuid.so session include password-auth 保存退出
[root@hf-01 vsftpd_user_conf]# vim /etc/vsftpd/vsftpd.conf 將anonymous_enable=YES 改成 anonymous_enable=NO 將#anon_upload_enable=YES 改成 anon_upload_enable=NO ,並取消註釋符 將#anon_mkdir_write_enable=YES 改成 anon_mkdir_write_enable=NO ,並取消註釋符 並增長如下內容 chroot_local_user=YES guest_enable=YES //打開虛擬用戶映射 guest_username=virftp //映射的用戶名 virtual_use_local_privs=YES //告訴服務,咱們如今用的虛擬用戶 user_config_dir=/etc/vsftpd/vsftpd_user_conf //定義虛擬用戶配置文件所在路徑 allow_writeable_chroot=YES 保存退出
[root@hf-01 vsftpd_user_conf]# systemctl start vsftpd [root@hf-01 vsftpd_user_conf]# ps aux |grep vsftpd root 3564 0.0 0.0 51136 564 ? Ss 06:49 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf root 3566 0.0 0.0 112676 984 pts/0 R+ 06:49 0:00 grep --color=auto vsftpd [root@hf-01 vsftpd_user_conf]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1607/master tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:40904 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 1250/rpc.mountd tcp 0 0 0.0.0.0:37459 0.0.0.0:* LISTEN 1224/rpc.statd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1227/sshd tcp6 0 0 ::1:25 :::* LISTEN 1607/master tcp6 0 0 :::2049 :::* LISTEN - tcp6 0 0 :::41381 :::* LISTEN 1224/rpc.statd tcp6 0 0 :::35465 :::* LISTEN - tcp6 0 0 :::3306 :::* LISTEN 1643/mysqld tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::20048 :::* LISTEN 1250/rpc.mountd tcp6 0 0 :::21 :::* LISTEN 3564/vsftpd tcp6 0 0 :::22 :::* LISTEN 1227/sshd [root@hf-01 vsftpd_user_conf]#
[root@hf-01 ~]# yum install -y lftp
[root@hf-01 ~]# lftp testuser1@127.0.0.1 口令: lftp testuser1@127.0.0.1:~> ls -rw-r--r-- 1 1002 1002 0 Jan 17 22:26 aming.txt lftp testuser1@127.0.0.1:/>
lftp testuser1@127.0.0.1:/> ? !<shell-command> (commands) alias [<name> [<value>]] attach [PID] bookmark [SUBCMD] cache [SUBCMD] cat [-b] <files> cd <rdir> chmod [OPTS] mode file... close [-a] [re]cls [opts] [path/][pattern] debug [<level>|off] [-o <file>] du [options] <dirs> exit [<code>|bg] get [OPTS] <rfile> [-o <lfile>] glob [OPTS] <cmd> <args> help [<cmd>] history -w file|-r file|-c|-l [cnt] jobs [-v] [<job_no...>] kill all|<job_no> lcd <ldir> lftp [OPTS] <site> ln [-s] <file1> <file2> ls [<args>] mget [OPTS] <files> mirror [OPTS] [remote [local]] mkdir [-p] <dirs> module name [args] more <files> mput [OPTS] <files> mrm <files> mv <file1> <file2> [re]nlist [<args>] open [OPTS] <site> pget [OPTS] <rfile> [-o <lfile>] put [OPTS] <lfile> [-o <rfile>] pwd [-p] queue [OPTS] [<cmd>] quote <cmd> repeat [OPTS] [delay] [command] rm [-r] [-f] <files> rmdir [-f] <dirs> scache [<session_no>] set [OPT] [<var> [<val>]] site <site-cmd> source <file> torrent [-O <dir>] <file|URL>... user <user|URL> [<pass>] wait [<jobno>] zcat <files> zmore <files> lftp testuser1@127.0.0.1:/>
lftp testuser1@127.0.0.1:~> get aming.txt lftp testuser1@127.0.0.1:/>
lftp testuser1@127.0.0.1:/> quit [root@hf-01 ~]#
[root@hf-01 ~]# ls 111 1_sorft.txt 2.txt.bak amin bb.txt lll.sh 123 1.txt 3.txt aming.txt grep sed 1.cap 234 aa.txt anaconda-ks.cfg haha shell 1_heard.txt 2.txt admin awk id.txt [root@hf-01 ~]#
第一種方案:mysql
C:\Users\Administrator\Documents\NetSarang\Xshell\Sessions Type `help' to browse available commnands. sftp:/root> ls dr-xr-x--- 5 root root 209 Jan 18 14:44 . dr-xr-xr-x 18 root root 256 Dec 16 16:03 .. -rw-r--r-- 1 root root 18 Dec 29 2013 .bash_logout -rw-r--r-- 1 root root 176 Dec 29 2013 .bash_profile -rw-r--r-- 1 root root 176 Dec 29 2013 .bashrc -rw-r--r-- 1 root root 100 Dec 29 2013 .cshrc -rw-r--r-- 1 root root 129 Dec 29 2013 .tcshrc -rw------- 1 root root 1422 Nov 15 16:01 anaconda-ks.cfg -rw------- 1 root root 14080 Jan 18 13:51 .bash_history drwxr----- 3 root root 19 Dec 15 10:57 .pki -rw------- 1 root root 6958 Jan 18 12:28 .viminfo drwxr-xr-x 3 root root 19 Jan 18 14:34 .local drwxr-xr-x 3 root root 18 Jan 18 14:34 .config -rw-r--r-- 1 root root 0 Jan 18 12:00 aming.txt sftp:/root>
sftp:/root> cd /tmp/ sftp:/tmp> ls drwxrwxrwt 10 root root 283 Jan 18 14:29 . dr-xr-xr-x 18 root root 256 Dec 16 16:03 .. drwxrwxrwt 2 root root 6 Nov 15 15:56 .X11-unix drwxrwxrwt 2 root root 6 Nov 15 15:56 .font-unix drwxrwxrwt 2 root root 6 Nov 15 15:56 .Test-unix drwxrwxrwt 2 root root 6 Nov 15 15:56 .XIM-unix drwxrwxrwt 2 root root 6 Nov 15 15:56 .ICE-unix drwxr-xr-x 3 root root 18 Dec 15 14:04 pear drwx------ 3 root root 17 Dec 19 10:08 systemd-private-6e73aa7860eb4d49858dd92d96b45716-vmtoolsd.service-q9Zmg0 drwx------ 3 root root 17 Dec 20 10:14 systemd-private-402b63f6eda14588932b1e1538c698b7-vmtoolsd.service-mv35lS srwxrwxrwx 1 mysql mysql 0 Dec 20 10:14 mysql.sock sftp:/tmp>
sftp:/tmp> get user.sql Fetching /tmp/user.sql to user.sql sftp: received 6.83 KB in 0.08 seconds