Adventure Time - Lady Rainicorn [Linux - error] ob for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
본문 바로가기
💻공부/Linux

[Linux - error] ob for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.

by 강켄트 2023. 4. 3.

 

상황은 이렇다.

ssh 포트를 변경해 주려고 

vi sshd_config 에서 port를 변경하고 변경내용을 적용시켜 주기 위해 systemctl restart sshd 입력했더니

다음과 같은 에러가 났다. 😧

 

해결방법

1️⃣ selinux의 동작 모드를 Permissive로 전환

동작 모드에는 enforce, permissive, disable가 있다.

동작 모드에 대한 자세한 설명을 아래에 첨부한다.

https://www.lesstif.com/ws/%EB%8F%99%EC%9E%91-%EB%AA%A8%EB%93%9C-48988478.html

 

아래와 같이 입력해서 setenforce의 옵션을 0으로 줘서 permissive 모드로 설정한다.

(1일 경우 enforce 모드, 0 일 경우 permissive 모드)

설정 내용은 getenforce 명령어로 확인할 수 있다. 

 permissive가 출력된걸 보니 잘 전환되었다!

 

selinux 동작 모드의 세부 정보를 보려면 명령어 sestatus를 사용할 수 있다.

permissive로 전환한 후에 sestatussestatus의 결과를 보면 

Current mode는 permissive이지만 Mode from config file 항목은 enforcing으로 두 개가 다르게 보인다.

 

 

setenforce 명령어로 설정한 모드는 영구적이지 않으며 재부팅하면 설정이 초기화되기 때문에

부팅 시 기본으로 설정할 모드는 설정 파일을 열어서 SELINUX=enforcing 항목을 수정하고 재부팅해야 반영된다.

 

 

2️⃣ SELINUX=disabled로 변경

아래 경로의 selinux으로 들어가서 SELINUX=disabled로 변경해 주자 

 

위 두 가지 설정을 완료한 뒤 

systemctl restart sshd를 실행하면 정상적으로 동작한다.

댓글