chmod g-w /home/$USER
chmod 700 /home/$USER/.ssh
chmod 600 /home/$USER/.ssh/authorized_keys
# ssh 서버 설치
apt install -y openssh-server
# 설정파일
sudo vi /etc/ssh/sshd_config
# root login 차단
PermitRootLogin no
## Port 22
Port 3022
# 공개키로 인증
PubkeyAuthentication yes
# 암호 인증 막기
PasswordAuthentication no
# 모드 변경
StrictModes no
# 공개키
AuthorizedKeysFile .ssh/authorized_keys
# 데몬 재구동
sudo systemctl restart sshd (Centos)
sudo systemctl restart ssh (Ubuntu)
# ssh 접속
ssh -o StrictHostKeyChecking=no -p 3322 linux_user@10.10.10.10
# ssh 접속 오류 로그
sudo tail -f /var/log/auth.log
# 오류 수정
"userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]"
오류는 최신 Ubuntu 버전(예: 22.04+)에서 ssh-rsa 알고리즘이 기본적으로 차단되었기 때문에 발생
sudo vi /etc/ssh/sshd_config
아래 2줄을 추가 또는 수정
PubkeyAcceptedAlgorithms +ssh-rsa
HostKeyAlgorithms +ssh-rsa
# rsa 키 생성
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
'Infra Structure > Linux' 카테고리의 다른 글
[Centos] NFS 설정 (0) | 2022.07.10 |
---|---|
[Linux] 쉘 실행시 내부에서 패스워드 입력 (0) | 2022.07.04 |
리눅스 계정 추가 (0) | 2022.06.13 |
ssh key 생성(원격서버접속) (0) | 2022.06.12 |
[Linux] ps -aux --forest | grep nginx (0) | 2022.06.01 |