Exportfs commands, NFS client issues, FTP introduction, using VSFTPD to build FTP

Source: Internet
Author: User
Tags file transfer protocol

14.4 Exportfs Command
    • Common options
      -A all mount or uninstall all
      -R Re-mount
      -U Uninstalls a directory
      -V Show shared directory

    • Uninstall on client
[[email protected] ~]# df-h file system capacity used available% mount point/dev/mapper/centos-root 17G 1.4G  16G 8%/devtmpfs 478M 0 478M 0%/devtmpfs 489M 0 489M 0% /dev/shmtmpfs 489M 6.7M 482M 2%/runtmpfs 489M 0 489M 0%/    SYS/FS/CGROUP/DEV/SDA1 1014M 125M 890M 13%/boottmpfs 98M 0 98M 0%/run/user/0192.168.1.15:/home/nfstestdir 17G 6.8G 11G 40%/mnt[[email protected] ~]# umount/mnt[[email&nb                 Sp;protected] ~]# df-h file system capacity used available% mount point/dev/mapper/centos-root 17G 1.4G 16G 8%/DEVTMPFS                    478M 0 478M 0%/devtmpfs 489M 0 489M 0%/dev/shmtmpfs 489M 6.7M 482M 2%/runtmpfs 489M 0 489M 0%/sys/fs/cgroup/dev/sda1 1014M 12 5M 890M 13%/boottmpfS 98M 0 98M 0%/run/user/0# You must uninstall the mount point on the client before you can restart the server nfs# otherwise, it may cause serious problems 
    • Operation on more than one machine
#用exportfs命令#以下是操作在服务端上#验证[[email protected] ~]# vim /etc/exports //增加 /tmp/192.168.1.0/24(rw,sync,no_root_squash)[[email protected] ~]# exportfs -arvexporting 192.168.1.16/24:/tmpexporting 192.168.1.0/24:/home/nfstestdir#不用重启nfs服务,配置文件就会生效#客户端上查看结果[[email protected] ~]# showmount -e 192.168.1.15Export list for 192.168.1.15:/tmp             192.168.1.16/24/home/nfstestdir 192.168.1.0/24#挂载到[[email protected] ~]# mount -t nfs 192.168.1.15:/tmp/ /mnt/[[email protected] ~]# ls /mnt/123.sqlmysqlbak.splmysql.sock
14.5 NFS Client Issues
    • This issue occurs with NFS version 4
    1. When a client mounts a shared directory, whether it is a root user or a normal user, a new file is created with the owner and group nobody
    2. Add-o nfsvers=3 when client mounts
[[email protected] ~]# mount -t nfs -oremount,nfsvers=3 192.168.1.15:tmp/ /mnt/#remount 重新挂载,通识指令nfsvers=3 版本为3
    1. Both the client and the server need
    2. Vim/etc/idmapd.conf
    3. Change ' #Domain = local.domain.edu ' to ' domain = xxx.com ' (Domain name customization), and then restart the RPCIDMAPD service
15.1 FTP Introduction
    • FTP is the abbreviation for the file Transfer Protocol (document Transfer Protocol), which is used to control the two-way transmission of files over the Internet.

    • The primary role of FTP is to have the user connect to a remote computer (which runs the FTP server program) and view the files on the remote computer, then copy the files from the remote computer to the local computer, or transfer the files from the local computer to the remote computer.
    • Small companies use more, large enterprises without FTP, because unsafe 15.2-15.3 use VSFTPD to build FTP
    • Bring your own vsftpd on CentOS
    • Installation
[[email protected] ~]# yum install -y vsftpd
    • Create a virtual user
[[email protected] ~]# useradd -s /sbin/nologin virftp#该用户无法登陆系统,只用于登陆FTP#virftp 为自定义用户名称
    • Virtual user's password file
[[email protected] ~]# vim /etc/vsftpd/vsftpd_login#内容如下,奇数行为用户名,偶数行为密码,多个用户就写多行testusertaoyuanftpuseraaaaaa
    • Configure permissions
[[email protected] ~]# chmod 600 /etc/vsftpd/vsftpd_login[[email protected] ~]# ls -l /etc/vsftpd/vsftpd_login -rw------- 1 root root 32 1月  17 16:06 /etc/vsftpd/vsftpd_login#密码文件为了安全,需要设置成600
    • Text file to binary file
[[email protected] ~]# db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db[[email protected] ~]# ls -l /etc/vsftpd/-rw------- 1 root root    32 1月  17 16:06 vsftpd_login-rw-r--r-- 1 root root 12288 1月  17 16:10 vsftpd_login.db
    • Virtual User Configuration file
#创建目录[[email protected] ~]# mkdir /etc/vsftpd/vsftpd_user_conf[[email protected] ~]# cd !$cd /etc/vsftpd/vsftpd_user_conf#配置文件的名称必须跟用户名称一样[[email protected] vsftpd_user_conf]# vim testuser#加入如下内容local_root=/home/virftp/testsueranonymous_enable=NOwrite_enable=YESlocal_umask=022anon_upload_enable=Noanon_mkdir_write_enable=NOidle_session_timeout=600data_connection_timeout=120max_clients=10

Parameter meaning
Local_root: Define a Virtual user's home directory
Anonymous_enable: Whether to allow anonymous users
Write_enable: Whether writable is allowed
Local_umask: Define permissions to create new files and directories
Anon_upload_enable: Allow anonymous users to upload
Anon_mkdir_write_enable: Whether anonymous users are allowed to create directories, writable
Idle_session_timeout: Set the connection idle time timeout (after uploading or downloading a file, idle time, define how long the connection is disconnected.) Unit s)
Data_connection_timeout: Time-out period for data transfer (unit: s)
Max_clients: Defines the maximum number of clients

    • Create a virtual user home directory
[[email protected] vsftpd_user_conf]# mkdir /home/virftp/testuser[[email protected] vsftpd_user_conf]# touch /home/virftp/testuser/taoyuan.txt#登录后可以看到该文件
    • Modify Permissions
[[email protected] vsftpd_user_conf]# chown -R virftp:virftp /home/virftp#为了防止是其他的用户权限,其他用户没有可写、可读的权限
    • Define a virtual user's password file
#编辑认证文件[[email protected] vsftpd_user_conf]# vim /etc/pam.d/vsftpd#操作比较重要,用来定义虚拟用户的密码文件路径#在第一行下插入如下的内容auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_loginaccount sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
    • Edit the VSFTPD master configuration file
[[email protected] vsftpd_user_conf]# vim /etc/vsftpd/vsftpd.conf#修改成如下内容anonymous_enable=NOanon_upload_enable=NOanon_mkdir_write_enable=NO#再最下一行增加如下内容chroot_local_user=YESguest_enable=YESguest_username=virftpvirtual_use_local_privs=YES #定义定义虚拟用户user_config_dir=/etc/vsftpd/vsftpd_user_conf #定义虚拟用户配置文件所在的路径allow_writeable_chroot=YES
    • Start the service
[[email protected] vsftpd_user_conf]# systemctl start vsftpd[[email protected] vsftpd_user_conf]# ps aux |        grep vsftproot 1732 0.0 0.0 53212 572? Ss 16:51 0:00/usr/sbin/vsftpd/etc/vsftpd/vsftpd.confroot 1734 0.0 0.0 112676 980 pts/0 s+ 16:51 0:0 0 grep--color=auto vsftp[[email protected] vsftpd_user_conf]# netstat-lntpactive Internet connections (only      servers) Proto recv-q send-q Local address Foreign address State Pid/program name 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 1124/rpc.mountd TCP 0 0 0.0.0.0:22 0.0.0.0:*      LISTEN 978/sshd TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1221/master TCP 0 0 0.0.0.0:51578 0.0.0.0:* LISTEN 1113/RPC.STATD TCP 0 0 0.0.0.0:2049 0.0.0.0:* listen-tcp 0 0 0.0.0.0:40712 0.0.0.0:* listen-tcp6 0 0::: 11 1:::* LISTEN 1/systemd tcp6 0 0::: 20048::: * LISTEN 1124/rpc.mountd tcp6 0 0::: +:::* L            Isten 1732/vsftpd tcp6 0 0::: +:::* LISTEN 978/sshd      TCP6 0 0:: 1:25:::* LISTEN 1221/master TCP6 0                0::: 35072:::* LISTEN 1113/rpc.statd tcp6 0 0::: 39489                    :::* listen-tcp6 0 0::: 2049:::* LISTEN-                   TCP6 0 0::: 3306:::* LISTEN 1364/mysqld          
    • Test
#安装ftp客户端[[email protected] vsftpd_user_conf]# yum install lftp#登录[[email protected] ~]# lftp [email protected]#?可以查看可执行的命令

Exportfs commands, NFS client issues, FTP introduction, using VSFTPD to build FTP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.