리눅스 SSH 설정 포트변경

 

 

CentOS 기준 SSH 설정위치는 /etc/ssh/sshd_config 에서 확인 가능합니다.

 

-> [root@localhost ~]# vi /etc/ssh/sshd_config 입력후 화면

 

# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

 

 

SSH 서비스 포트는 22로 규악되어 있습니다. 하지만 보안을 위해 포트를 변경해주는것도 가능합니다.

#주석을 지우고 원하는 포트로 변경하시면 됩니다. 

 

포트변경 후 sshd 재시작 명령어 입력

-> [root@localhost ~]# systemctl restart sshd

 

포트가 정상적으로 올라와있는지 확인

-> [root@localhost ~]# netstat -nlpt

 

서버에 요청 중입니다. 잠시만 기다려 주십시오...