사용자 도구

사이트 도구


linux:ssh

차이

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

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
linux:ssh [2017/04/26 10:57]
kwon37xi [접속 유지 Keep connection]
linux:ssh [2019/11/13 23:04]
kwon37xi [~/.ssh/config]
줄 5: 줄 5:
   * [[http://server.dzone.com/articles/9-ssh-do%E2%80%99s-and-don%E2%80%99ts|9 SSH Do’s and Don’ts]]   * [[http://server.dzone.com/articles/9-ssh-do%E2%80%99s-and-don%E2%80%99ts|9 SSH Do’s and Don’ts]]
   * [[http://www.cyberciti.biz/faq/linux-unix-test-internet-connection-download-upload-speed/|Linux / Unix: Test Internet Connection Speed From Console Over SSH Command Line]]   * [[http://www.cyberciti.biz/faq/linux-unix-test-internet-connection-download-upload-speed/|Linux / Unix: Test Internet Connection Speed From Console Over SSH Command Line]]
 +  * [[linux:asbrucm|asbru-cm]]
 +  * [[linux:pac|PAC]]
  
 ===== Private Key 생성 ===== ===== Private Key 생성 =====
줄 13: 줄 15:
   * ''id_rsa'' 파일은 개인키로 자신의 PC(Client)에 둔다.   * ''id_rsa'' 파일은 개인키로 자신의 PC(Client)에 둔다.
   * ''*.pub'' 파일은 공개키로 접속 대상 서버 계정의 ''~/.ssh/authorized_keys'' 파일에 그 내용을 추가한다.   * ''*.pub'' 파일은 공개키로 접속 대상 서버 계정의 ''~/.ssh/authorized_keys'' 파일에 그 내용을 추가한다.
-  * ''~/.ssh''에 있는 파일은 ''600'' 권한으로 설정해야한다.+  * ''~/.ssh''에 있는 파일은 ''600'' 권한으로 설정해야한다. 해당 디렉토리도 권한 확인이 필요하다.<code sh> 
 +chmod 700 ~/.ssh 
 +</code>
  
 ===== ssh-agent ===== ===== ssh-agent =====
줄 23: 줄 27:
 </code> </code>
   * 키 등록이 안 될 경우 키 파일의 권한이 **0600**이 맞는지 확인 해 본다.   * 키 등록이 안 될 경우 키 파일의 권한이 **0600**이 맞는지 확인 해 본다.
 +
 +<code sh>
 +chmod 600 ~/.ssh/id_rsa*
 +</code>
 +  * [[https://unix.stackexchange.com/questions/90853/how-can-i-run-ssh-add-automatically-without-a-password-prompt|ssh agent - How can I run ssh-add automatically, without a password prompt? - Unix & Linux Stack Exchange]]
  
 ===== SSH 접속 인사 텍스트 ===== ===== SSH 접속 인사 텍스트 =====
   * ''/etc/motd'' 파일 편집하면 SSH 접속시 인사말을 지정할 수 있다.   * ''/etc/motd'' 파일 편집하면 SSH 접속시 인사말을 지정할 수 있다.
 +  * 그런데 ''update-motd'' 애플리케이션이 작동하고 있을 때는 ''/etc/update-motd.d'' 의 스크립트가 순서대로 실행된 결과로 매번 ''/etc/motd'' 파일이 덮어써진다. 
 +  * 따라서 ''update-motd'' 사용시에는 ''/etc/update-motd.d''에 원하는 스크립트를 넣어둬야 한다.
  
 ===== ~/.ssh/config ===== ===== ~/.ssh/config =====
줄 32: 줄 42:
     * [[http://haruair.com/blog/2219|ssh config로 ssh 접속 간편하게 하기]]     * [[http://haruair.com/blog/2219|ssh config로 ssh 접속 간편하게 하기]]
     * [[http://nerderati.com/2011/03/simplify-your-life-with-an-ssh-config-file/|Simplify Your Life With an SSH Config File]]     * [[http://nerderati.com/2011/03/simplify-your-life-with-an-ssh-config-file/|Simplify Your Life With an SSH Config File]]
 +    * 파일 권한<code sh>
 +chmod 600 ~/.ssh/config
 +</code>
   * ''~/.ssh/config''<code sh>   * ''~/.ssh/config''<code sh>
 # 기본형태. ~/.ssh/id_rsa 를 사용할 경우 혹은 일반 비밀번호 인증의 경우 # 기본형태. ~/.ssh/id_rsa 를 사용할 경우 혹은 일반 비밀번호 인증의 경우
줄 47: 줄 60:
 # 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]
줄 56: 줄 70:
     IdentityFile ~/.ssh/[private key]     IdentityFile ~/.ssh/[private key]
 </code> </code>
 +  * [[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''에 설정한 파일이 뒤로 추가되는 형태로 시도된다.
  
 ===== 접속 유지 Keep connection ===== ===== 접속 유지 Keep connection =====
줄 74: 줄 91:
 chmod 600 ~/.ssh/config chmod 600 ~/.ssh/config
 </code> </code>
-  * ssh 데몬 재시작+  * ssh 데몬 재시작<code sh> 
 +sudo service ssh restart 
 +</code> 
 + 
 +혹은 명령행 옵션을 직접 줘도 됨 
 + 
 +<code sh> 
 +ssh  -o ServerAliveInterval=60 hostname 
 +</code>
  
 ===== Text 파일 Gzip 압축 전송 : 다른 서버의 파일을 현재 서버로 전송 ===== ===== Text 파일 Gzip 압축 전송 : 다른 서버의 파일을 현재 서버로 전송 =====
줄 120: 줄 145:
 </code> </code>
  
 +
 +===== known_hosts 에 미리 호스트 추가 =====
 +[[http://bcho.tistory.com/1227|SSH known_host 메모]]
 +<code sh>
 +ssh-keyscan -t rsa host명 >> ~/.ssh/known_host
 +ssh-keyscan -t rsa -f host명들 이들어있는 파일명 >> ~/.ssh/known_host
 +</code>
 +
 +=====  no matching cipher found. =====
 +아래와 같은 오류 발생시..
 +
 +>> 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'' 마지막에 다음과 같은 설정 추가
 +<code>
 +Ciphers aes128-cbc,aes192-cbc,aes256-cbc
 +# 필요한 경우
 +KexAlgorithms +diffie-hellman-group1-sha1
 +</code>
 +
 +혹은 명령행에 암호화 방식을 ''-c'' 옵션으로 직접 지정한다.
 +
 +<code sh>
 +ssh -c aes128-cbc kwon37xi@xxx.xx.xx.xx
 +</code>
  
linux/ssh.txt · 마지막으로 수정됨: 2023/01/30 17:19 저자 kwon37xi