macOS ssh server 활성화 하기.

macOS Monterey에서 ssh 접속 허용하기.

macOS 터미널에서 localhost로 ssh 접속을 했을때, 아래와 같은 메시지가 보이면 ssh 서버가 실행되지 않고 있는 상태라고 생각할 수 있다.

snowfox@snowfoxui-MacBookPro ~ % ssh localhost
ssh: connect to host localhost port 22: Connection refused
snowfox@snowfoxui-MacBookPro ~ % 

다른 컴퓨터에서 접속해 보면, 역시 접속되지 않는다.

snowfox@wolf:~$ ssh snowfox@192.168.100.14
ssh: connect to host 192.168.100.14 port 22: Connection refused

ssh 서버가 실행중인지를 확인하려면 systemsetup 명령을 사용한다.

snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -getremotelogin
Password:
Remote Login: Off

macOS에서 ssh 서버를 실행하려면, 위와 동일 한 명령어에 -setremotelogin 옵션을 사용한다.

snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -setremotelogin on
setremotelogin: Turning Remote Login on or off requires Full Disk Access privileges.
snowfox@snowfoxui-MacBookPro ~ % 

하지만, macOS Monterey에서는 위와 같은 메시지가 나오며 적용이 되지 않는다. 위의 메시지대로 full disk access 권한이 없어서 발생하는 문제인데, 이것은 터미널이 full disk access 권한을 가지도록 해 주면 해결된다.
먼저, 시스템 환경설정-> 보안 및 개인 정보 보호 -> 전체 디스크 접근 권한 (개인 정보 보호) 탭 선택 후 터미널을 선택하면 된다.(command는 모르겠음;)

시스템 환경설정 -> 보안 및 개인 정보 보호

전체 디스크 접근 권한 선택후 변경(왼쪽 아래 자물쇠가 잠겨있는지 꼭 확인하자!)

이제, systemsetup 명령어로 ssh 서버를 실행한다.

snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -setremotelogin on 
Password:

별다른 메시지가 보이지 않는다. 이제, 설정을 확인해 본다.

snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -getremotelogin
Remote Login: On

다른 컴퓨터에서 접속해 본다.

snowfox@wolf:~$ ssh snowfox@192.168.100.14
The authenticity of host '192.168.100.14 (192.168.100.14)' can't be established.
ECDSA key fingerprint is SHA256:/CfkLLVx75bEV4CpvxQKtYSoViu9+idOHNVu/g4fklc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.100.14' (ECDSA) to the list of known hosts.
Password:
Last login: Mon Dec 19 22:51:21 2022
snowfox@snowfoxui-MacBookPro ~ % 

ssh 서버 종료는,

snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -setremotelogin off
Do you really want to turn remote login off? If you do, you will lose this connection and can only turn it back on locally at the server (yes/no)? yes
snowfox@snowfoxui-MacBookPro ~ %                                     
snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -getremotelogin    
Remote Login: Off

GUI에서 ssh 접속 설정 변경은,
시스템환경설정 -> 공유 -> 원격로그인을 체크.

터미널에서 확인 해보면 아래처럼 On으로 변경된다.

snowfox@snowfoxui-MacBookPro ~ % sudo systemsetup -getremotelogin
Remote Login: On

답글 남기기

Your email address will not be published.