'ssh-copy-id'에 해당되는 글 2건

ssh-copy-id 에러시 키 복사 방법



아래와 같은 에러가 나는 경우에 ssh key 를 원격지에 복사하는 방법입니다.


# ssh-copy-id root@192.168.1.100

Pseudo-terminal will not be allocated because stdin is not a terminal.

ssh: Could not resolve hostname exec sh -c 'cd; umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys && (test -x /sbi: Name or service not known



▶ cat & ssh 로 복사


# cat .ssh/id_rsa.pub | ssh root@192.168.1.100 "cat >> ~/.ssh/authorized_keys"



원격지에 authorized_keys 파일이 아직 없는 경우에는 아래처럼 하면 됩니다.


# cat .ssh/id_rsa.pub | ssh root@192.168.1.100 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"



▶ scp 로 복사


# scp .ssh/id_rsa.pub root@192.168.1.100:~/.ssh/authorized_keys


scp 로 복사를 할 수도 있겠지만 authoirized_keys 파일이 있다면 다른 파일 명으로 복사한 다음에 원격지에서 cat 로 추가하여 주면 됩니다.



ssh 포트가 default 22 번이 아니라면 ssh, ssh-copy-id 는 -p포트번호 를 추가하여 주면 됩니다.


scp 는 -P포트번호 입니다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

SSH KEY 원격지서버에 복사하기



원격지 서버에 암호입력 없이 접속하기 위해서는 SSH KEY 를 생성해서 원격지 서버에 복사해 두어야 한다.


ssh-keygen 과 ssh-copy-id 명령어를 이용해보자.


[root@conoha-jp ~]# 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:

3d:ec:1e:82:64:8a:6a:98:66:ce:5d:60:73:26:05:6e root@conoha-jp

The key's randomart image is:

+--[ RSA 2048]----+

|   .             |

|  . .            |

|   E .           |

|  . .    o       |

|   = oo S +      |

|  ..*+ . . .     |

|... ... . o      |

|+=. .    o .     |

|*o .      .      |

+-----------------+


옵션 생략하고 ssh-keygen 으로 하여도 된다.


생성된 키를 원격지 서버에 복사해보자.


[root@conoha-jp ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.3

The authenticity of host '192.168.1.3 (192.168.1.3)' can't be established.

ECDSA key fingerprint is 68:03:15:9f:4a:96:27:6a:d0:26:9d:91:2e:f9:e2:ea.

Are you sure you want to continue connecting (yes/no)? yes

/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

root@192.168.1.3's password:


Number of key(s) added: 1


Now try logging into the machine, with:   "ssh 'root@192.168.1.3'"

and check to make sure that only the key(s) you wanted were added.


옵션 없이 ssh-copy-id root@192.168.1.3 으로 하여도 된다.


ssh 포트가 22번이 아니라면 -p 옵션을 사용하면 된다.


예) ssh-copy-id -p포트번호 root@192.168.1.3



192.168.1.3 서버에 복사가 되었다.


이제 부터는 암호 입력없이 접속이 가능할 것이다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,