CentOS 포트 변경 방법

1. 포트 확인

# netstat -an|grep LISTEN 
tcp        0      0 0.0.0.0:22           0.0.0.0:*               LISTEN 
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN 
tcp6       0      0 :::22                :::*                    LISTEN 
tcp6       0      0 ::1:25                  :::*                    LISTEN

기본 포트 22번 포트로 LISTEN 하는걸 알수 있다.

2. 설정파일 변경

#  vi /etc/ssh/sshd_config

Port 22 주석처리 후 원하는 포트로 변경

예시:Port 85

 

3. sshd 재시작

# systemctl restart sshd.service

 

오류가 발생한다.

# systemctl restart sshd.service 
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.

 

status 로 상세정보를 보라고 한다.

SELINUX의 경우 보안 때문에 먼저 포트를 열어줘야 한다.

 

# semanage port -a -t ssh_port_t -p tcp 1999

 

4. sshd 재시작 후 포트 확인

# systemctl restart sshd.service
# netstat -n|grep LISTEN
tcp        0      0 0.0.0.0:85           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp6       0      0 :::85                :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN 

 

5. 새로운 터미널로 85 포트로 접속

 

 

  • 0 사용자에게 유용한 정보 제공
이 답변이 도움이 되었나요?
« Back