Linux Learning Summary (47) NFS service configuration Next

Source: Internet
Author: User
Tags file transfer protocol

Last episode speaking of NFS server configuration, this article begins with client operations.

1 NFS Client Mount

Yum Install-y nfs-utils
showmount -e 192.168.226.129This IP is an NFS server-side IP

mount -t nfs 192.168.226.129:/home/nfstestdir /mnt/
Df-h

Touch/mnt/test.txt
Ls-l/mnt/test.txt

You can see that both the owner and the group of the file are MySQL, corresponding to Uid,gid is 1000, because our NFS server configuration is like this
/home/nfsdir 192.168.226.130(rw,sync,all_squash,anonuid=1000,anongid=1000)
The meanings in parentheses are: Read/write, synchronize, restrict all users who use NFS service as ordinary users, define the Uid,gid of the limited user to be 1000

2 Exportfs Command

NFS can not be restarted at will, it is necessary to remove the customer-service mount first, so the operation is very troublesome, inefficient. So how do we make it work quickly when we add a shared directory to the server? We can use the EXPORTFS command to have the NFS configuration file/etc/exports
Reload.
Exportfs command usage is relatively straightforward.
Exportfs-arv Reload the configuration file, update the service
-A means all directories (mount or unload)
-R Re-mount
-V Show shared directory
-u Uninstall a directory//For exampleexportfs -uv 192.168.226.130:/home/nfsdir
Edit the configuration file on the server and add a shared directory
Vi/etc/exports
/mnt/testdir 192.168.226.0/24(rw,sync,no_root_squash)
Mkdir/mnt/testdir
chmod 777/mnt/testdir
Save exit
exportfs -arv

Mount the shared directory on the client
mount -t nfs 192.168.226.129:/mnt/testdir /media/
df -h |egrep ‘mnt|media‘

Create a file to see its permissions
Touch/media/test.txt
Ll/media/test.txt

Last small bug
In CentOS 6, the client file belongs to the owner and the group is nobody
Workaround:
Specify NFS version when client mounts,-o nfsvers=3
Uninstall umount/mnt/and then specify version mount
Mount-t Nfs-o nfsvers=3 192.168.226.129:/mnt/testdir/mnt/

3 Introduction to FTP

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 an FTP server program), view the files on the remote computer, and then copy the files from the remote computer to the local computer, or transfer the files from the local computer to the remote computer.

4 VSFTPD Build FTP Service

Bring your own vsftpd on CentOS
Yum install-y vsftpd//install VSFTPD server
Useradd-s/sbin/nologin virftp//VSFTPD can support login using System account, for security reasons, we create a virtual account
Create a user password file
Vim/etc/vsftpd/vsftpd_login//content as follows, odd behavior username, even behavior password, multiple users write multiple lines
TestUser1
Lvlinux
chmod 600 /etc/vsftpd/vsftpd_loginChange permissions
Replace a text file with a binary file
db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db
Create and user-corresponding profiles
Mkdir/etc/vsftpd/vsftpd_user_conf
Cd/etc/vsftpd/vsftpd_user_conf
Vim TestUser1//Add the following:

local_root=/home/virftp/testuser1 // 指定账号家目录anonymous_enable=NO  // 不容许匿名账号登录write_enable=YES   //标示可写local_umask=022   // 指定umaskanon_upload_enable=NO  // 不容许匿名账号上传文件anon_mkdir_write_enable=NO  //不容许匿名账号可写idle_session_timeout=600data_connection_timeout=120max_clients=10

Create a table of contents, specify the genus Master Group
Mkdir/home/virftp/testuser1
Touch/home/virftp/testuser1/.txt
Chown-r virftp:virftp/home/virftp
Edit the associated user password profile
VIM/ETC/PAM.D/VSFTPD//At the front Plus

auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_loginaccount sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login

To edit a global configuration file
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=YESguest_enable=YESguest_username=virftpvirtual_use_local_privs=YESuser_config_dir=/etc/vsftpd/vsftpd_user_confallow_writeable_chroot=YES

Test
Systemctl start vsftpd//Start VSFTPD Service
Yum install-y lftp//install client software
lftp [email protected]
Execute command LS to see if normal output
viewing logs/var/log/messages and/var/log/secure if not normal

Linux Learning Summary (47) NFS service configuration Next

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.