SSH 접속 password 입력없이 RSA키로 접속하기

ssh 접속할 때마다 password 치기가 귀찮다…

클라이언트에서 키 생성

$ ssh-keygen -t rsa -N '' -q -f ~/.ssh/id_rsa

접속하려는 서버로 공개키 복사.

$ ssh-copy-id <account>@<server hostname>

위의 복사는 아래와 동등하다. 위 명령을 했다면 아래를 할 필요는 없음.

$ scp ~/.ssh/id_rsa.pub <account>@<server hostname>:.ssh/authorized_keys

예를 들면 다음과 같이 한다.

ssh-keygen -t rsa -b 4096 -q -N '' -f ~/.ssh/id_rsa_dasomoli_nas
ssh-copy-id -i ~/.ssh/id_rsa_dasomoli_nas.pub dasomoli@nas.dasomoli.org

ssh 접속 시 no matching key exchange method found. 문제

SSH 접속 시 다음과 같은 에러가 발생할 때가 있다.

Unable to negotiate with blog.dasomoli.org: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

OpenSSH가 7.0이상이면, 요 키 교환 알고리즘이 기본으로 켜져 있지 않아서 나는 문제인데, 다음과 같은 방법으로 해결 가능하다.

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@host

이걸 명령 줄 때마다 하긴 귀찮으니까 ~/.ssh/config 파일 안에 다음 내용을 추가하면 된다.

Host blog.dasomoli.org
KexAlgorithms +diffie-hellman-group1-sha1

참고: Using OpenSSH with legacy SSH implementations