사용자 도구

사이트 도구


linux:ssh

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
linux:ssh [2019/11/13 22:55]
kwon37xi [Private Key 생성]
linux:ssh [2020/06/24 10:27]
kwon37xi [no matching cipher found.]
줄 10: 줄 10:
 ===== Private Key 생성 ===== ===== Private Key 생성 =====
 <code sh> <code sh>
-ssh-keygen -t rsa+ssh-keygen -t rsa -b 4096 -m pem -C "your_email@example.com"
 </code> </code>
   * Passphrase를 항상 넣는 것이 좋다.   * Passphrase를 항상 넣는 것이 좋다.
   * ''id_rsa'' 파일은 개인키로 자신의 PC(Client)에 둔다.   * ''id_rsa'' 파일은 개인키로 자신의 PC(Client)에 둔다.
   * ''*.pub'' 파일은 공개키로 접속 대상 서버 계정의 ''~/.ssh/authorized_keys'' 파일에 그 내용을 추가한다.   * ''*.pub'' 파일은 공개키로 접속 대상 서버 계정의 ''~/.ssh/authorized_keys'' 파일에 그 내용을 추가한다.
 +  * [[git:github|Github]] 참조.
 +  * ''ssh-keygen'' 최근 버전에서 ''-m pem'' 옵션이 없으면 private Key 헤더가 ''%%-----BEGIN OPENSSH PRIVATE KEY-----%%''로 시작한다면 호환 안되는 경우가 있을 수 있다.
 +  * [[:upsource|Upsource]] 등 일부 과거 시스템들의 호환성으 높이려면 ''-m pem'' 옵션 추가할 것. 헤더가 ''%%-----BEGIN RSA PRIVATE KEY-----%%''로 시작해야한다.
   * ''~/.ssh''에 있는 파일은 ''600'' 권한으로 설정해야한다. 해당 디렉토리도 권한 확인이 필요하다.<code sh>   * ''~/.ssh''에 있는 파일은 ''600'' 권한으로 설정해야한다. 해당 디렉토리도 권한 확인이 필요하다.<code sh>
 chmod 700 ~/.ssh chmod 700 ~/.ssh
줄 50: 줄 53:
     HostName IP 혹은 hostname     HostName IP 혹은 hostname
     User 계정명     User 계정명
 +    IdentitiesOnly yes
  
 # 특정 key 지정 # 특정 key 지정
줄 57: 줄 61:
     PreferredAuthentications publickey     PreferredAuthentications publickey
     IdentityFile ~/.ssh/[private key]     IdentityFile ~/.ssh/[private key]
 +    IdentitiesOnly yes
  
 # github.com git 계정 접속시에 대한 처리 # github.com git 계정 접속시에 대한 처리
 Host github.com Host github.com
 +    HostName github.com
     User git     User git
     IdentityFile ~/.ssh/[github private key]     IdentityFile ~/.ssh/[github private key]
 +    IdentitiesOnly yes
          
 # 동일 2차 도메인 사용시 # 동일 2차 도메인 사용시
줄 68: 줄 75:
     PreferredAuthentications publickey     PreferredAuthentications publickey
     IdentityFile ~/.ssh/[private key]     IdentityFile ~/.ssh/[private key]
 +    IdentitiesOnly yes
 </code> </code>
   * [[https://gist.github.com/jexchan/2351996|동일 HostName, 동일 User 다중 Key]] ''Host github.com-SSHID'' 에서 ''Host'' 의 값을 ''github.com-myid'' 형태로 특정 값을 줘서 처리할 수 있고, 그 뒤 부터 ssh ''github.com-myid'' 같은 호출이 정상 작동한다.   * [[https://gist.github.com/jexchan/2351996|동일 HostName, 동일 User 다중 Key]] ''Host github.com-SSHID'' 에서 ''Host'' 의 값을 ''github.com-myid'' 형태로 특정 값을 줘서 처리할 수 있고, 그 뒤 부터 ssh ''github.com-myid'' 같은 호출이 정상 작동한다.
 +    * [[https://stackoverflow.com/questions/7927750/specify-an-ssh-key-for-git-push-for-a-given-domain|Specify an SSH key for git push for a given domain - Stack Overflow]]
 +    * [[https://serverfault.com/questions/450796/how-could-i-stop-ssh-offering-a-wrong-key/450807#450807|gitolite - How could I stop ssh offering a wrong key? - Server Fault]] ''IdentitiesOnly yes'' 설정도 주는게 좋다. 그렇지 않으면 우선 순위상에 있는 다른 키 파일들 뒤에 ''IdentityFile''에 설정한 파일이 뒤로 추가되는 형태로 시도된다.(''~/.ssh/id_dsa, ~/.ssh/id_rsa'' 등이 더 우선된다)
  
 ===== 접속 유지 Keep connection ===== ===== 접속 유지 Keep connection =====
줄 155: 줄 165:
 >> no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc@lysator.liu.se >> no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc@lysator.liu.se
  
-''~/.ssh/config'' 마지막에 다음과 같은 설정 추가+혹은  
 +>> no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 
 + 
 + 
 +''~/.ssh/config'' 마지막에 다음과 같은 설정 추가(알고리즘은 알아서..)
 <code> <code>
 Ciphers aes128-cbc,aes192-cbc,aes256-cbc Ciphers aes128-cbc,aes192-cbc,aes256-cbc
linux/ssh.txt · 마지막으로 수정됨: 2023/01/30 17:19 저자 kwon37xi