더북(TheBook)

Tip 패스워드 없이 접속할 수 있는 ssh-key 설정하기


우분투 16.04 LTS 버전부터는 SSH 서버의 환경설정을 변경해야 ssh-key를 사용할 수 있습니다. 이전 버전에서는 ssh-key를 만들고 키를 이용해 접속할 때 패스워드를 입력하지 않아도 되었지만 이제는 패스워드를 입력해야만 접속할 수 있습니다. 지금부터 우분투 16.04 버전에서 ssh-key를 이용해 패스워드 없이 접속할 수 있도록 설정해 보겠습니다.

1. ssh-key를 이용해 접속하려는 노드에 OpenSSH를 설치합니다. 여기서는 우분투와 함께 설치했으므로 별도로 설치하지 않습니다. OpenSSH가 설치되어 있다면 /etc/ssh/sshd_config 파일을 열어 PasswordAuthentication 옵션을 no로 설정합니다. 해당 옵션이 주석으로 처리되어 있다면 주석을 해제합니다. 컨트롤러 노드에서 컴퓨트 노드로 접속할 것이므로 컴퓨트 노드의 환경설정 파일을 수정합니다.

root@compute:~# vi /etc/ssh/sshd_config
...
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication = no


2. SSH 서비스를 재시작하고 정상적으로 실행되는지 status를 확인합니다.

root@compute:~# service ssh restart
root@compute:~# service ssh status
 ssh.service - OpenBSD Secure Shell server
    Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: 
enabled)
    Active: active (running) since Tue 2016-06-28 13:27:51 KST; 6s ago
  Main PID: 17759 (sshd)
     Tasks: 2
    Memory: 5.1M
       CPU: 21ms
    CGroup: /system.slice/ssh.service
            ├─ 2296 sshd: nalee [priv]  
            └─17759 /usr/sbin/sshd -D

Jun 28 13:27:51 compute systemd[1]: Starting OpenBSD Secure Shell server...
Jun 28 13:27:51 compute sshd[17759]: Server listening on 0.0.0.0 port 22.
Jun 28 13:27:51 compute sshd[17759]: Server listening on :: port 22.
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.