#!/bin/bash # # 2014/09/02 # 1) 禁用selinux # modify /etc/sysconfig/selinux # to: SELINUX=disabled # and reboot later. cp -a /etc/selinux/config /etc/selinux/config.bak echo ‘SELINUX=disabled‘ >/etc/selinux/config # 2)清空firewall iptables-save >/root/rc.firewall.txt iptables -F service iptables save # 3)设置SSH,端口 cat << _SSHCONFIG > sshd_config.new Port 22 Protocol 2 SyslogFacility AUTHPRIV LogLevel VERBOSE PermitRootLogin yes PasswordAuthentication yes ChallengeResponseAuthentication no UsePAM yes AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE AcceptEnv XMODIFIERS UseDNS no Subsystem sftp /usr/libexec/openssh/sftp-server -f LOCAL0 -l VERBOSE _SSHCONFIG mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak mv sshd_config.new /etc/ssh/sshd_config service sshd restart echo ‘注意:selinux重启后再更改port,以免连接不上ssh端口;建议后续再禁用root,password登录,改用key登录;‘ #设置rsyslog echo "local0.* /var/log/sftp.log" >/etc/rsyslog.d/sftp.conf service rsyslog restart
时间: 2024-10-12 08:48:40