포트 22: 18.04 업그레이드 후 연결이 거부되었습니다.

포트 22: 18.04 업그레이드 후 연결이 거부되었습니다.

몇 달 전, 마침내 서버를 18.04로 업그레이드했습니다. OVH에서 호스팅하는 VM입니다. 설치가 완료되면 VM을 다시 시작했습니다. 그리고 걱정이 되어서 SSH 접속이 되지 않더군요.

업그레이드 전에는 포트 44를 사용하여 VM에 연결하고 ufw를 방화벽으로 사용하여 22 포트에서는 모든 연결을 차단하고 44 포트에서는 허용했습니다. 업그레이드하는 동안 sshd 구성 파일을 과충전할지 묻는 질문을 받았지만 그렇게 하지 않기로 결정했습니다.

다행히도 OVH를 사용하면 복구 모드에서 VM을 다시 시작할 수 있습니다. 이를 통해 내 VM에 연결할 수 있었고 명령을 사용하여 mount /dev/sda2/ /mnt/내 루트 디렉터리에 액세스할 수 있었습니다.

포트 22를 차단하고 포트 44를 허용하는 것에 대해 이야기하는 sshd 구성 또는 ufw 파일의 모든 줄을 제거하려고 시도했습니다. 포트 22도 허용하도록 변경했습니다.

아무것도 작동하지 않습니다.

내 user.rules는 다음과 같습니다.

*filter
:ufw-user-input - [0:0]
:ufw-user-output - [0:0]
:ufw-user-forward - [0:0]
:ufw-before-logging-input - [0:0]
:ufw-before-logging-output - [0:0]
:ufw-before-logging-forward - [0:0]
:ufw-user-logging-input - [0:0]
:ufw-user-logging-output - [0:0]
:ufw-user-logging-forward - [0:0]
:ufw-after-logging-input - [0:0]
:ufw-after-logging-output - [0:0]
:ufw-after-logging-forward - [0:0]
:ufw-logging-deny - [0:0]
:ufw-logging-allow - [0:0]
:ufw-user-limit - [0:0]
:ufw-user-limit-accept - [0:0]
### RULES ###

### tuple ### allow tcp 22 0.0.0.0/0 any 0.0.0.0/0 in
-A ufw-user-input -p tcp --dport 22 -j ACCEPT

### tuple ### allow tcp 44 0.0.0.0/0 any 0.0.0.0/0 in
-A ufw-user-input -p tcp --dport 44 -j ACCEPT

### END RULES ###

### LOGGING ###
-A ufw-after-logging-input -j LOG --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-A ufw-after-logging-forward -j LOG --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-I ufw-logging-deny -m conntrack --ctstate INVALID -j RETURN -m limit --limit 3/min --limit-burst 10
-A ufw-logging-deny -j LOG --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-A ufw-logging-allow -j LOG --log-prefix "[UFW ALLOW] " -m limit --limit 3/min --limit-burst 10
### END LOGGING ###

### RATE LIMITING ###
-A ufw-user-limit -m limit --limit 3/minute -j LOG --log-prefix "[UFW LIMIT BLOCK] "
-A ufw-user-limit -j REJECT
-A ufw-user-limit-accept -j ACCEPT
### END RATE LIMITING ###
COMMIT

내 sshd_config 파일은 다음과 같습니다.

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22,44
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
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
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
MaxStartups 5:15:30
AllowUsers myuser

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes #no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
Ciphers [email protected],[email protected],aes256-ctr,aes128-ctr
MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,hmac-sha1
KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

마지막으로 ssh 디렉토리에는 많은 구성 파일이 포함되어 있습니다.

rescue:/mnt/etc/ssh# ls
moduli      ssh_config.dpkg-dist  sshd_config.orig  ssh_host_dsa_key      ssh_host_ecdsa_key      ssh_host_ed25519_key  ssh_host_key      ssh_host_rsa_key  ssh_import_id
ssh_config  sshd_config       sshd_config.ucf-dist  ssh_host_dsa_key.pub  ssh_host_ecdsa_key.pub  ssh_host_ed25519_key.pub  ssh_host_key.pub  ssh_host_rsa_key.pub

문제는 어디에 있습니까? 다시 시작한 후에도 UFW가 구성을 로드하지 않고 여전히 이전 버전을 사용하고 있다고 생각하기 시작했습니다. 또는 포트 22를 허용하더라도 여러 sshd_config 파일이 있습니다.

도움을 주셔서 감사합니다

관련 정보