Skip to content

Instantly share code, notes, and snippets.

@yoshi0309
Last active August 29, 2015 14:06
Show Gist options
  • Save yoshi0309/9b4ef8205d69cde48ed3 to your computer and use it in GitHub Desktop.
Save yoshi0309/9b4ef8205d69cde48ed3 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
perl -pi -e 's/^#?Port 22$/Port 22\nPort 443/' /etc/ssh/sshd_config
semanage port -m -t ssh_port_t -p tcp 443
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited
service iptables save
service iptables restart
service sshd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment