[openssh] [SELinux] Cannot bind any address

Dec 15 02:21:34 MyServer systemd[1]: sshd.service: Main process exited, code=exited, status=255/EXCEPTION
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ An ExecStart= process belonging to unit sshd.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 255.
Dec 15 02:21:34 MyServer sshd[60725]: fatal: Cannot bind any address.
Dec 15 02:21:34 MyServer systemd[1]: sshd.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ The unit sshd.service has entered the 'failed' state with result 'exit-code'.
Dec 15 02:21:34 MyServer systemd[1]: Failed to start OpenSSH server daemon.
░░ Subject: A start job for unit sshd.service has failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ A start job for unit sshd.service has finished with a failure.
░░
░░ The job identifier is 2485 and the job result is failed.

  SSH 포트를 바꾸고 openssh를 다시 시작했을 때의 오류를 'jounalctl -xe'로 본 것이다. 보안 강화 리눅스(SEelinux)에 바꾼 SSH 포트를 등록하지 않아서 생기는 오류이다.

  보안 강화 리눅스가 켜져 있는지는 getenfoce 명령으로 알아볼 수 있다.

# getenforce
Enforcing

  Enforcing이라고 나오면 SELinux가 켜진 상태이고 Permissive라고 나오면 꺼진 상태이다. 아래처럼 setenforce 명령으로 잠시 켜고 꺼 볼 수 있다.

# setenforce 1
(SELinux 켜기)
# setenforce 0
(SELinux 끄기)

  바꾸려는 SSH 포트가 1010이면 아래처럼 등록해 준다

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

  SELinux에 등록된 SSH 포트는 아래 명령으로 확인할 수 있다. (SSH를 지울 때는 semanage port -d -t 1010 -p tcp 1010)

# semanage port -l | grep ssh
ssh_port_t                     tcp      1010, 22

  새로운 포트(1010)를 등록한 뒤에 SSH(openssh)를 다시 시작해 본다. (CentOS)

# systemctl restart sshd

 

 

2023/12/15 11:59 2023/12/15 11:59
글 걸기 주소 : 이 글에는 글을 걸 수 없습니다.

덧글을 달아 주세요