인프라(infra)

ssh-copy-id 키 복사후 비밀번호 없이 접속

주피터0410 2023. 3. 30. 14:50

131번 root 로 접속

whoami 로 현재 root 체크

[root@servera131 pki]# whoami
root

 

gitlab-runner 유저 변경

[root@servera131 pki]# su gitlab-runner
[gitlab-runner@servera131 pki]$ whoami
gitlab-runner
[gitlab-runner@servera131 pki]$ cd ~
[gitlab-runner@servera131 ~]$ pwd
/home/gitlab-runner

 

ssh-keygen  공개키/개인키가 생성(.ssh 디렉토리 안에 생성됨) - 기존에 생성하였다면 생략 가능

[gitlab-runner@servera131 ~]$ ssh-keygen -t rsa
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:Y72tOcAcke9aN0rNqauUA3ASfH12x6C0HHw3eYXjLb8 root@1416567744ff
The key's randomart image is:
+---[RSA 3072]----+
|   ..  . oo .o oo|
|    ... +o++o O .|
|    o..  =+o + = |
|     +  ...   o .|
|      .oSo.o . o |
|       o+o+o*   .|
|        +=.+..  .|
|       ...+o   E |
|        ..+o     |
+----[SHA256]-----+

 

ssh-copy-id 키 복사

[gitlab-runner@servera131 ~]$ ssh-copy-id ftp_id@xxx.xxx.xxx.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/gitlab-runner/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ftp_id@xxx.xxx.xxx.131's password: [ftp_id비번 입력]

[gitlab-runner@servera131 ~]$ ssh -p '22' 'ftp_id@xxx.xxx.xxx.131'
Last login: Thu Mar 30 14:18:11 2023 from xxx.xxx.xxx.131
입력하고 접속하면 비밀번호 없이 접속 가능

[ftp_id@servera131 ~]$

'인프라(infra)' 카테고리의 다른 글

ubuntu 18.04 + Janus Gateway 설치  (0) 2023.06.30
xampp 기본설정  (0) 2023.04.12
git username / password 저장  (0) 2023.03.30
Git Runners 등록  (0) 2023.03.30