====== SSH 활용하기 ====== ===== ssh 인증없애기 ===== - host1에서 host2로 인증없이 접근을 한다고 가정하자. - host1 계정에서 ssh-key를 생성한다. starlits@host1:~/.ssh$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/starlits/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/starlits/.ssh/id_rsa. Your public key has been saved in /home/starlits/.ssh/id_rsa.pub. The key fingerprint is: 57:d0:5c:a5:3a:d7:18:90:11:57:62:f4:0a:69:d8:2d starlits@twasadmin - ~/.ssh 아래에 id_rsa.pub id_rsa 파일이 존재하는지 확인한다. starlits@twasadmin:~/.ssh$ ls authorized_keys id_rsa id_rsa.pub known_hosts $ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlAEudFqJh7JtdOW6Cv713kL1k0zyaOyzPeHPj4eQ7wjOj/ero5k4DCcmacm/CPvtLrPDsKxMQUdyQQ4cOnMNRYVNX2pZL/NuREhrhbdUsGEwP9T49lpw4KLmPNxTnRFaiH17VA7M0Q0UP3a82ic74svbmZgRrmGPW1teh+aF3VYgYCBI1nsK2jWava6ULXH7GBmrXBCFHBtWDJH2xxe6Xev94ssDeUcdVaNNQKwGjXYwMiFNHktJM2g38KpkZYt02snx4AI6l91rsxOpmH6f76kWGn8eI1fYH8p21edMZDJMkITj6Opb8KAXJgQso14GhdRYJGMRkvTO6dLqKKL0UQ== starlits@host1 - id_rsa.pub 를 host2 에 .ssh/ 아래로 카피한다. starlits@host1:~/.ssh$ scp id_rsa.pub host2:.ssh/ - host2에서 id_rsa.pub 를 authorized_keys 이름으로 변경한다. starlits@host2:~/.ssh$ ls id_rsa.pub known_hosts starlits@host2:~/.ssh$ mv id_rsa.pub authorized_keys starlits@host2:~/.ssh$ ls authorized_keys known_hosts - host1 에서 host2로 접근하면 암호를 물어보지 않는다. - host1 에서 host2로 명령을 직접 실행할 수도 있다. starlits@host1:~/.ssh$ ssh host2 PATH=/bin hostname host2