리눅스 다른 서버에 비밀번호 없이 ssh 접속
예제)
- A(123.111.111.111) 에서 B(123.111.111.112)로 ssh접속 및 명령어 전송
- B에는 test계정으로 접속
A에서 키생성
[boya@A ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/boya/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/boya/.ssh/id_rsa.
Your public key has been saved in /home/boya/.ssh/id_rsa.pub.
The key fingerprint is:
20:41:a9:71:6d:c6:bf:1b:11:52:23:12:46:51:68:40 boya@A
The key's randomart image is:
+--[ RSA 2048]----+
|oE=o. .o. |
| oo. .. . |
| . . ..+oo |
| ...o*= |
| oSo.. |
| .. |
| . . |
| .. |
| .. |
+-----------------+
A에서 생성한 키를 B에 복사
[boya@A ~]$ ssh-copy-id test@123.111.111.112
test@123.111.111.112's password:
Now try logging into the machine, with "ssh 'test@123.111.111.112'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
A에서 B에 접속
ssh test@123.111.111.112
A에서 B에 명령어 전송(ls -alst)
ssh test@123.111.111.112 ls -alst