Linux

change openSSH default port on ubuntu 22.10

PSAwesome 2022. 12. 3. 22:53
반응형

 

문제점

22.10부터 openSSH 버전이 바뀌어서 socket 통신의 설정이 필요.

 

PubKey 설정을 하지 않고 아래대로 진행하면, ssh 접속이 안 됩니다.

PubKey 설정을 하실 예정이라면 먼저 아래 글을 확인하시길 권장합니다.

2022.10.03 - [Linux] - 리눅스 서버 설치 후 해야할 작업 (for ssh)

 

ufw allow 5678 및 reload 후 

sshd_config 파일을 아래와 같이 변경해도 defaultPort가 바뀌지 않는 현상이 생겼습니다.

# /etc/ssh/sshd_config 



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

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

# 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.

Include /etc/ssh/sshd_config.d/*.conf

Port 5678

LogLevel INFO


PermitRootLogin prohibit-password

PubkeyAuthentication yes


AuthorizedKeysFile      .ssh/authorized_keys .ssh/authorized_keys2

 

 

해결: socket ListenStream 추가

1. create directory 

sudo mkdir -p /etc/systemd/system/ssh.socket.d

2. change chown (제 유저 이름이 ps입니다.)

sudo chown ps:ps /etc/systemd/system/ssh.socket.d/

3. create socket conf

cat >/etc/systemd/system/ssh.socket.d/listen.conf <<EOF
[Socket]
ListenStream=
ListenStream=5678
EOF

4. reload daemon and ssh

sudo systemctl daemon-reload

sudo systemctl restart ssh

 

5. access

pub_key를 이미 복사한 상태라 바로 접속이 될 수 있었습니다.

 

 

22.10 버전을 설치한 이유는

iwlwifi

해당 wifi 패키지 (wifi가 계속 끊기는 현상) 오류로 우분투 설치에 너무 골머리를 앓았기 때문입니다.

 

 

감사합니다.

반응형

'Linux' 카테고리의 다른 글

oh-my-zsh auto completion  (0) 2022.12.21
install nvidia-smi on ubuntu 22.04  (0) 2022.12.04
centos 7 server 설치 후 설정  (0) 2022.10.06
리눅스 서버 설치 후 해야할 작업 (for ssh)  (0) 2022.10.03
Ubuntu 20.04 - 한글 설정하기  (0) 2020.05.05