Linux下常用服务程序配置讲解

NFS:
nfs的组成:rpc.portmapper, rpc.nfsd, rpc.mountd
nfs的安装:sudo aptitude install nfs-kernel-server or nfs-user-server
nfs的启动和停止:sudo /etc/init.d/nfs-kernel-server restart|stop|start
nfs的检查:ps ax | grep nfsd ps -aux | grep portmap
nfs的配置:/etc/exports文件当中
/usr 192.168.1.100 (rw) /home/xp 192.168.1.12(rw,sync) *(ro,async)

选项说明:
no_root_squash 远端root用户对nfs目录具有完全访问权限
rw 读写,默认 ro 只读 sync 同步
配置检查:exportfs -rv
客户端:
查看NFS共享内容: showmount -e 服务器主机名或ip
安装内容:sudo mount 192.168.1.100:/home/share /mnt/nfsdir
卸载内容:sudo umount /mnt/nfsdir

------------------------------
FTP: port:21
安装:sudo aptitude install vsftpd
启动和停止:sudo /etc/init.d/vsftd start|stop|restart
配置文件:/etc/vsftpd.conf
PAM配置:/etc/pam.d/vsftpd
用户访问控制:/etc/vsftpd.ftpusers写在当中的本地用户静止登录 /etc/vsftpd.user_list
设置空闲会话中断时间:idle_session_timeout=600 (second)
设置空闲数据连接的中断时间:data_connection_timeout=120
设置客户端空闲时的自动中断和激活连接时间:accept_timeout=60 connect_timeout=60

vsftpd匿名上传配置:
anon_upload_enable = Yes
anon_mkdir_write_enable = Yes
anon_other_write_enable = Yes
anon_world_readable_only = No

配置速率限制和每用户的连接数限制:
local_max_rate
anon_max_rate
max_per_ip
max_clients

基于本地用户的配置:
userlist_enable = Yes
userlist_deny = Yes
userlist_file = /etc/vsftpd.user_list

客户端操作:
get remotefile [localfile]
put localfile [remotefile]
mget remote-files
mput local-files

lftp命令:
mirror [option] [remote [local]]
-c 续传
-R 上传整个目录
-r 不用递归到目录中
-n 只下载较新的档案

------------------------------
有些服务程序需要xinetd: sudo aptitude install xinetd
启动xinetd:sudo /etc/init.d/xinetd reload
测试xinetd:ps ax | grep xinetd
xinetd的配置文件有:/etc/xinetd.conf /etc/xinetd.d/目录下的与各服务一一对应的配置文件

-----------------------
TFTP:无连接的UDP传送文件,一般用于小文件,实现简单 port:69
安装:sudo aptitude install tftpd
安装程序会在/etc/inetd.conf中添加一行:tftp dgram udp wait nobody .....
xinet要使用需要转换:itox -daemon_dir /usr/sbin < /etc/inetd.conf
创建文件/etc/xinetd.d/tftp 内容是转换得到的tftp段
//////////////////////////tftp有此部分////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
看/etc/xinetd.d/tftp文件中server_args = /srv/tftp, 则手工创建:
sudo mkdir /srv/tftp
sudo chmod a+w /srv/tftp
/////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
重启xinetd以读取配置文件:sudo /etc/init.d/xinetd restart

客户端:
sudo aptitude install atftp
atftp 127.0.0.1

---------------------
TELNET: port:23
安装:sudo aptitude install telnetd
创建文件:/etc/xinetd.d/telnet 内容是/etc/inetd.conf转换过来的段
重启xinetd,读取新的配置文件,服务开通

------------------
SSH: port:22
安装:sudo aptitude install ssh
查看:sudo netstat -apn | grep ":22"

客户端登录:ssh user@ip 退出:logout
登录以后可以像操作自己的电脑一样使用

不登录对方使用:
scp localfile user@ip:/remote_path or remote_file
scp user@ip:/remote_file localfile or localpath

/etc/hosts.deny
sudo /etc/init.d/ssh start|stop