ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -P ""
scp ~/.ssh/id_rsa.pub 서버호스트:~/.ssh/클라이언트_id_rsa.pub
ssh 서버호스트
cat 클라이언트_id_rsa.pub >> ~/.ssh/authorized_keys
rm 클라이언트_id_rsa.pub
이런 번잡한 복사 및 덧붙이기 절차를 간단하게 처리할 수 있는 도구가 있음
ssh-copy-id 원격계정@원격서버주소
ssh -v로 테스트
sudo /usr/local/bin/sshd -D -d
-D 옵션은 deamon mode로 동작하지 않도록 지정
반드시 서버의 에러 메시지를 확인할 필요가 있음
config의 호스트 별 설정이 기록되어 있다면 제대로 작성되었는지 확인할 것
특히 IdentityFile은 제공할 퍼블릭 키와 짝이 되는 프라이빗 키 파일을 지정해야 함
클라이언트 쪽에서 인식할 수 없는 서버의 호스트명이 적혀있다면 수정할 것
authorized_keys 파일의 permission이 644가 아니어서 오동작하는 경우가 있음
chmod 0644 ~/.ssh/authorized_keys
- 오후 12:33:53.597 sshd[82377]: error: Could not load host key: /etc/ssh_host_rsa_key
- 오후 12:33:53.597 sshd[82377]: error: Could not load host key: /etc/ssh_host_dsa_key
sudo ssh-keygen -t dsa -f /etc/ssh_host_dsa_key < /dev/null
sudo ssh-keygen -t rsa -b 4096 -f /etc/ssh_host_rsa_key < /dev/null
sshd가 authorized_keys 파일을 읽지 않도록 설정되어 있는 경우, /etc/sshd/sshd_config 파일 수정이 필요함
chattr -i /etc/ssh/sshd_config
vi로 편집
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
chattr +i /etc/ssh/sshd_config