# rsa 키 생성

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

 

# 키생성

/home/계정명/.ssh 디렉토리에 키생성

id_rsa : (개인키) 
id_rsa.pub : (공개키) 원격 서버 authorized_keys에 저장

 

# 원격서버에서 공개키 등록

$cat >> ~/.ssh/authorized_keys

복사한 내용을 붙여넣은 뒤 엔터로 줄바꿈 해준뒤 ctrl+d로 저장

or 

vi 편집기로 공개키를 추가해준다.

or

[로컬]#ssh-copy-id [계정명]@[원격IP주소]
>[암호입력]

 

# 원격접속 체크
ssh 계정명@서버ip

 

#개인키파일명 지정(미지정시 id_rsa파일)

ssh -i id_rsa 계정명@서버ip   

 

# port 지정

ssh -p 22 계정명@서버ip

 

# Host Key Checking 비활성화

ssh -i id_rsa -o StrictHostKeyChecking=no ubuntu@10.10.10.10

 

 

# 권한 설정

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

 

# 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

 

sudo systemctl restart ssh

 

# Build

Execute shell

 

ssh user@192.168.0.10 '
df -h
ls -al
'

 

 

# host key checking 비활성화

ssh -o StrictHostKeyChecking=no user@192.168.0.10

 

 

 

 

'Infra Structure > Linux' 카테고리의 다른 글

SSH 원격접속 설정  (0) 2022.07.01
리눅스 계정 추가  (0) 2022.06.13
[Linux] ps -aux --forest | grep nginx  (0) 2022.06.01
scp 파일 전송 명령어  (0) 2022.05.26
ll 명령어 등록하기(ls -al)  (0) 2022.05.25

+ Recent posts