DEV Community

Beaver Bridge
Beaver Bridge

Posted on

비밀번호 입력 없이 ssh로 서버 접속

~/.ssh/id_rsa 파일이 없을 때

cd ~/.ssh

ssh-keygen -t rsa -b 4096 -C "my_name.home"
Enter file in which to save the key (/Users/mac/.ssh/id_rsa): # 비워두기. 그냥 Enter 치기
Enter passphrase (empty for no passphrase): # 비워두기. 그냥 Enter 치기
Enter same passphrase again: # 비워두기. 그냥 Enter 치기

# remote의 ~/.ssh/authorized_keys에 저장(초기 설정인 경우, 비밀번호 입력해야할 수 있음)
ssh-copy-id -i ~/.ssh/id_rsa.pub [remote-host]
# ssh-copy-id -i ~/.ssh/id_rsa.pub my-account@192.168.1.205 
Enter fullscreen mode Exit fullscreen mode

새로운 ~/.ssh/id_rsa 파일을 사용하고 싶을 때

cd ~/.ssh

ssh-keygen -t rsa -b 4096 -C "my_name.home"
Enter file in which to save the key (/Users/mac/.ssh/id_rsa): ./id_rsa_qa_rocky
Enter passphrase (empty for no passphrase): # 비워두기. 그냥 Enter 치기
Enter same passphrase again: # 비워두기. 그냥 Enter 치기

# remote의 ~/.ssh/authorized_keys에 저장(초기 설정인 경우, 비밀번호 입력해야할 수 있음)
ssh-copy-id -i ~/.ssh/id_rsa_qa_rocky.pub [remote-host]
# ssh-copy-id -i ~/.ssh/id_rsa.pub my-account@192.168.1.205

# ./ssh/config 에 지정
Enter fullscreen mode Exit fullscreen mode

.ssh/config 에 새로 만든 id_rsa 파일 지정

host qa_rocky
    user my_account
    identityfile ~/.ssh/id_rsa_qa_rocky
    hostname 192.168.1.205
Enter fullscreen mode Exit fullscreen mode

접속하기

ssh qa_rocky
# ssh my-account@192.168.1.205 로 접속하면 비밀번호 물어봄
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.