SSH key login 설정법

A. 주사용처

서버 백업

서버간 데이터 동기화시 rsync 이용시

kt cloud / AWS cloud 로그인시

B. 설정 방법

1. 클라이언트 서버에서 ssh-keygen

root@control:/home/userssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:gzcO5QMV6N1NVHZKaxXLXd0z6SzNXeV/V3JoLipAs98 root@control
The key"s randomart image is:
+---[RSA 2048]----+
| .o. ...+.@|
| .. .o.@B|
| .+... o %oX|
| ..B. . .= B+|
| = S . o +|
| * = . . o|
| + E |
| . |
| |
+----[SHA256]-----+

2. key 확인

root@control:/home/userll /root/.ssh/
total 20
drwx------ 2 root root 4096 Jul 16 20:41 ./
drwx------ 4 root root 4096 Jul 13 04:05 ../
-rw------- 1 root root 1675 Jul 16 20:41 id_rsa
-rw-r--r-- 1 root root 394 Jul 16 20:41 id_rsa.pub
-rw-r--r-- 1 root root 222 Jul 3 03:13 known_hosts

3. 원격 서버로 key 복사

root@control:/home/userscp $HOME/.ssh/id_rsa.pub user@com1:id_rsa.pub
assword:
id_rsa.pub

# 키 파일 내용 복사

# authorized_keys 파일은 /etc/ssh/sshd_config 에서 확인 필요. authorized_keys2 인 경우도 있음.

root@com1:/home/usercat $HOME/id_rsa.pub >> $HOME/.ssh/authorized_keys

root@com1:/home/userchmod 600 $HOME/.ssh/authorized_keys

4. 원격 서버 로그인

root@control:/home/userssh root@com1
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-31-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

20 packages can be updated.
4 updates are security updates.


*** System restart required ***


C. 체크 사항

1. centos 7 : authorized_keys2

2. ubuntu 16.04 : authorized_keys

3.authorized_keys(2) 파일의 권한이 600이 아니거나, 사용자가 틀릴경우 로그인 안됨.







https://www.aiocp.co.kr/ ( 딥러닝,머신러닝 서버 판매 ,컨설팅) https://bigbangcloud.co.kr/ ( GPU 클라우드 서비스) ::: AI 서버의 모든것 ::: 인공지능의 시작~ (주)이호스트ICT
ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.


PDS
Á¦¸ñPage 4/76
2014-05   4442076   Á¤ÀºÁØ1
2015-12   998604   ¹é¸Þ°¡
2023-02   61926   °£Àå°ÔÀå
2023-02   33609   FOXBI
2023-02   31837   ºÐ³ëÀÇ´Ù¿îÈú
2023-01   33592   ±è´ö¿µ
2023-01   33223   ±è´ö¿µ
2023-01   34278   ´Ù·ÕÀÌ
2023-01   22850   ¾öû³­x
2023-01   18389   ¹Â³ë
2023-01   13734   Çã¾î
2023-01   16048   ¹Â³ë
2023-01   17340   ¼öÆÛ½ÎÀ̾ð
2023-01   13150   ÇöÁø
2023-01   14261   ¹Â³ë
2022-12   17495   °£Àå°ÔÀå
2022-12   21328   ¹Â³ë
2022-12   15940   ¾ÆÀ×½´ÆÛ¸Ç
2022-11   28617   ½ºÄµl¹ÎÇö±â
2022-11   38785   ¹Ú¹®Çü
2022-10   43761   ½º¿þÀÎ
2022-10   40843   ¼öÆÛ½ÎÀ̾ð