-- Your mail server should accept mail from remote hosts and localhost
-- harry must be able to receive mail from remote hosts
-- Mail delivered to mary should spool into the default mail spool for mary /var/spool/mail/mary
install the postfix,
yum install -y postfixstart the postfix and make it auto on when booting,
service postfix start
chkconfig postfix onmodify the main.cf
vim /etc/postfix/main.cf
the original inet_interfaces is localhost, if needs to receive the internal and external mails, needs to switch on inet_interfaces = all, and comments off localhost, as following,
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhostharry is local user, so he can receive the external mail, mary should spool into the default mail spool for mary /var/spool/mail/mary, this one also no need to do anything.
Restart the service,
service postfix restart
chkconfig postfix oncheck ports is on now,
netstat -ntulp | grep :25check the hostname,
postconf myhostnameif the hostname is incorrect, needs to modify the /etc/postfix/main.cf, in the line of mydestination add "server3.example.com"
mydestination=.....,server3.example.com
send an email to test the SMTP,
echo "hello mary" | mail -s "subject" mary@server3.example.commail -u mary
modify the /etc/aliase
vim /etc/aliaseadd one line as following, and add harry at the end, mail transferred to mary and harry also can receive mail.
harry mary,harryupdate the database,
newaliases
test the result,
echo "hello harry" | mail -s "subject" harry@server3.example.commail -u mary
mail -u harrychkconfig postfix on
--when you input "kernel" parameter to the shell script that will return "user"
--when you input "user" parameter to the shell script that will return "kernel"
--while script no parameter or parameter is wrong,standard error "usage:/root/program kernel|user"
vim /root/programadd the source code,
#!/bin/bash
if
[ "$1" == "user" ];
then
echo "kernel";
elif
[ "$1" == "kernel" ];
then
echo "user";
else
echo "usage:/root/program kernel|user."
fihere needs to pay attention to one thing, [ "$1" == "user" ], there are some spaces in the middle, if you missed out the space, the shell program will not work. test the result, ./program user will output kernel, ./program kernel, will output user, if ./program, it will output "usage:/root/program kernel|user."
another way to achieve this is by using the case program,
#!/bin/bash
case $1 in
user)
echo "kernel" ;;
kernel)
echo "user" ;;
*) echo 'usage:/root/program kernel|user.'
esac
4, ftp service, allow anonymous to upload file, upload folder path as /var/ftp/upload
lock the local user to home directory, limit certain user to home directory
limit certain user to login to ftp service.
install the vsftp,
yum install vsftpstart the service and make it auto on,
service vsftpd restart
chkconfig vsftpd onmodify the vsftpd.conf,
vim /etc/vsftpd/vsftpd.confuncomment following two lines, save and restart the vsftpd service,
anon_upload_enable=YES
anon_mkdir_write_enable=YESrestart the serviceservice vsftpd restartcreate the uploading folder,
mkdir -p /var/ftp/uploadchange the access right,
chown ftp.ftp /var/ftp/upload
chmod 775 /var/ftp/uploadchange the selinux bool value,
getsebool -a | grep ftpsetsebool -P allow_ftpd-anon_write on
Setsebool -P allow_ftpd_anon_full_access ontest the result,
lftp 192.168.0.103ls and !ls to display the folder,
put post.loglock the user to home directory,
vim /etc/vsftpd/vsftpd.confswitch on chroot_local_user
chroot_local_user=YESrestart the vsftp
service vsftpd restarttest the result,
ftp 192.168.0.103login as student, and try to go to other folder,
cd /var/ftpit will return error, "550 failed to change directory"
limit certain user to home directory,
vim /etc/vsftpd/vsftpd.confuncomment following two lines,
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_listcreate file chroot_list,
vim /etc/vsftpd/chroot_listadd sutdent and visitor
limit certain user to login ftp service, modify /etc/vsftpd/ftpusers, to add the users needs to be limited.
vim /etc/vsftpd/ftpusers

本文介绍如何配置Postfix邮件服务以实现远程邮件接收及别名设置,并详细说明了如何安装和配置vsftpd以允许匿名上传文件并限制用户访问。
290

被折叠的 条评论
为什么被折叠?



