ãããã® VPS ã«ç»é²ãã¦ã¿ã(2)
ãã¹ã¯ã¼ãããã«æ¥ãã®ã§ç¶ãã§ãã
ã¾ãã¯ã°ã«ã¼ãã¨ã¦ã¼ã¶ã¾ãã
root ã®ãã¹ã¯ã¼ããå¤æ´ãã¦ããã¾ãã
# passwd
sudo ã許å¯ããã°ã«ã¼ãã¨ï¼ããã«å±ããç§ã®ã¦ã¼ã¶ã¢ã«ã¦ã³ãã追å ã
# groupadd -g 3000 sudoers # useradd -u 1000 mayu # usermod -G sudoers mayu # passwd mayu
visudo ã«ã¯ä»¥ä¸ã®è¨è¿°ã追å ãsudoers group ã«å±ããã¦ã¼ã¶ã« sudo 権éãä¸ãã¦ããã¾ãã
# visudo
%sudoers ALL=(ALL) NOPASSWD:ALL
ç¶ã㦠ssh å¨ã
ãããã㯠mayu ã§ãã°ã¤ã³ãã¦ä½æ¥ãã¾ãã
$ sudo vi /etc/ssh/sshd_config
root ãã°ã¤ã³ã®ç¦æ¢ã¨ï¼ãã¹ã¯ã¼ããã°ã¤ã³ã®ç¦æ¢ããªãã㨠sshd ã®å¾ ã¡åããã¼ããå¤æ´ã10022 ã£ã¦å®çªãããããªï¼ AllowGroups ã AllowUsers ã¯â¦â¦å ¬ééµèªè¨¼ã«ãããï¼ä»åã¯è¨å®ããªããã¨ã«ãã¾ããã
--- /etc/ssh/sshd_config.orig 2010-09-13 16:26:31.000000000 +0900 +++ /etc/ssh/sshd_config 2010-09-13 16:27:44.000000000 +0900 @@ -10,7 +10,7 @@ # possible, but leave them commented. Uncommented options change a # default value. -#Port 22 +Port 10022 #Protocol 2,1 Protocol 2 #AddressFamily any @@ -36,7 +36,7 @@ # Authentication: #LoginGraceTime 2m -#PermitRootLogin yes +PermitRootLogin no #StrictModes yes #MaxAuthTries 6 @@ -57,7 +57,7 @@ # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no -PasswordAuthentication yes +PasswordAuthentication no # Change to no to disable s/key passwords #ChallengeResponseAuthentication yes
ã§ï¼èªåã®ã¢ã«ã¦ã³ãã« ssh ã®å ¬ééµãç»é²ã
$ mkdir -p ~/.ssh $ cat >> ~/.ssh/authorized_keys ssh-rsa AAAA(ãã«ããã«ã ^D $ chmod 600 ~/.ssh/authorized_keys $ chmod 700 ~/.ssh
sshd ã restert ãã¦ããã¾ãã
$ sudo /etc/init.d/sshd restart
iptables ã®ç·¨é
ãã®è¾ºããã ãã ãããåãããªããªã£ã¦ãã¾ããâ¦â¦ã
ãã¶ãå¤åãã¯å ¨è¨±å¯ï¼å åã㯠80 㨠10022 ã ã空ãã¦ãç¶æ â¦â¦ã«ãªã£ã¦ãã¨æããã ãã©èªä¿¡ãªãã§ãã
$ vi ~/iptables.rules
*filter -A INPUT -i lo -j ACCEPT -A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -p tcp --dport 10022 -j ACCEPT -A OUTPUT -j ACCEPT -A INPUT -j REJECT -A FORWARD -j REJECT COMMIT
$ sudo /sbin/iptables-restore < /home/mayu/iptables.rules
è¨å®å 容ã®ç¢ºèª
$ sudo /sbin/iptables -L
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere ACCEPT icmp -- anywhere anywhere icmp any ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:10022 REJECT all -- anywhere anywhere reject-with icmp-port-unreachable Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-port-unreachable Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere
åã£ã¦ãã®ããªãâ¦â¦ãä½ãæ£ããã®ããåãããªãã¨è¦ã¦ãåãããªãã§ãã(>_<)
åèµ·åãã¦ã大ä¸å¤«ãªããã«ä¿åãã¦ããã¾ãã
$ sudo /sbin/service iptables save
ä¸è¦ãªãµã¼ãã¹ã®åæ¢
å°ãã§ãå¿«é©ã«ããããªããã£ã¨ãã£ã¦èª°ããè¨ã£ã¦ãã®ã§ã
$ sudo /sbin/chkconfig --list | grep :on
acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off lvm2-monitor 0:off 1:on 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off readahead_early 0:off 1:off 2:on 3:on 4:on 5:on 6:off readahead_later 0:off 1:off 2:off 3:off 4:off 5:on 6:off sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ãã®è¾ºæ¢ãã¦ããã¾ããããããã¶ãè¦ããªãâ¦â¦ã¨æãã
$ sudo /sbin/chkconfig acpid off $ sudo /sbin/chkconfig lvm2-monitor off $ sudo /sbin/chkconfig readahead_later off $ sudo /sbin/chkconfig sendmail off
ã§ï¼åèµ·åãã¡ããã¨ãã°ã¤ã³ã§ããããªã¼(ç¬)
$ sudo /sbin/shutdown -r now