Linux,Unix,BSD

sshd port 변경

채윤아빠 2014. 5. 21. 09:22
728x90
반응형


보안상의 이유로 sshd port를 다음과 같이 변경하였습니다.

  • sshd_config 에서 Port 수정
    # vi /etc/ssh/sshd_config 
    
    Port 2222
    
  • services 에서 ssh port 수정
    # vi /etc/serivces
    
    ssh             2222/tcp                           # SSH Remote Login Protocol
    ssh             2222/udp                           # SSH Remote Login Protocol
    
  • sshd 재시작
    [root@utillighting ssh]# cd /etc/rc.d/init.d
    [root@utillighting init.d]# ./sshd restart
    sshd 를 정지 중:                                           [  OK  ]
    sshd (을)를 시작 중:                                       [  OK  ]
    [root@utillighting init.d]# 
    
  • fail2ban 재시작
    # service fail2ban restart
    Stopping fail2ban:                                         [  OK  ]
    Starting fail2ban:                                         [  OK  ]
    
  • iptables에서 fail2ban 적용 확인
    # iptables -L
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    fail2ban-SSH  tcp  --  anywhere             anywhere            tcp dpt:ssh 
    fail2ban-SSH  tcp  --  anywhere             anywhere            tcp dpt:22 
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain fail2ban-SSH (2 references)
    target     prot opt source               destination         
    RETURN     all  --  anywhere             anywhere