4. 编写⼀个名为ftp.sh的shell程序,完成vsftpd的⾃动安装、配置和启动。 要求:1.采⽤stand-alone模式启动 2.禁⽌匿名启动
时间: 2024-02-12 12:09:55 浏览: 42
好的,根据你的要求,以下是ftp.sh脚本的代码:
```
#!/bin/bash
# 自动安装vsftpd
yum install vsftpd -y
# 配置vsftpd.conf
sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf
echo "local_enable=YES" >> /etc/vsftpd/vsftpd.conf
echo "write_enable=YES" >> /etc/vsftpd/vsftpd.conf
echo "local_umask=022" >> /etc/vsftpd/vsftpd.conf
echo "dirmessage_enable=YES" >> /etc/vsftpd/vsftpd.conf
echo "xferlog_enable=YES" >> /etc/vsftpd/vsftpd.conf
echo "connect_from_port_20=YES" >> /etc/vsftpd/vsftpd.conf
echo "xferlog_std_format=YES" >> /etc/vsftpd/vsftpd.conf
echo "chroot_local_user=YES" >> /etc/vsftpd/vsftpd.conf
echo "listen=YES" >> /etc/vsftpd/vsftpd.conf
echo "tcp_wrappers=YES" >> /etc/vsftpd/vsftpd.conf
# 启动vsftpd服务
systemctl start vsftpd.service
systemctl enable vsftpd.service
```
这个脚本会自动安装vsftpd,并对vsftpd.conf进行配置,最后启动vsftpd服务。同时,匿名启动被禁止,只允许本地用户登录。注意,这个脚本需要以root权限运行。