SSH Key λ§λ€κΈ° & μ€μ
ssh-keygen
ssh-keygen 컀λ©λλ₯Ό μ΄μ©ν΄μ ν€λ₯Ό μμ±νλ€.
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):[μν°ν€]
Enter passphrase (empty for no passphrase): [μν°ν€]
Enter same passphrase again: [μν°ν€]
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
Code language: Bash (bash)
~/.ssh
ν΄λμ id_rsa
, id_rsa.pub
ν€κ° μμ±λλ€.
public key synologyμ μ μ‘ (with: ssh-copy-id)
ssh-copy-id
컀맨λκ° κ°λ₯νλ€λ©΄ κ°λ¨νκ² public key
νμΌμ μ μ‘ν μ μλ€.
ssh-copy-id
λ λ‘컬νΈμ€νΈμ κ³΅μ© ν€λ₯Ό μ격 νΈμ€νΈμ authorized_keys
νμΌμ 볡μ¬ν©λλ€. κ·Έλ¦¬κ³ μλ§μ κΆνμ remote-host μ μ μ μλ λͺ©λ‘ νμΌ, ν΄λμ λΆμ¬ν©λλ€.
- ν
~/
~/.ssh
~/.ssh/authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
Code language: Bash (bash)
μ λͺ λ Ήμ΄λ₯Ό μ€ννλ©΄ ssh λ‘κ·ΈμΈμ μλ
home νμΌ κΆν νμΈ
κΆνμ΄ ssh-copy-id
λ‘ μ€μ λκ² μ§λ§ νλ²λ νμΈν©μλ€.
chmod 755 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Code language: Bash (bash)
Synology sshd config
sudo vim /etc/ssh/sshd_config
Code language: Bash (bash)
μλμ κ°μ λ΄μ©μΌλ‘ μ€μ μ λ³κ²½ν΄μ€λ€.
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
Code language: plaintext (plaintext)
DSM7.0μΌλ‘ λμ΄μ€λ©΄μ RSAAuthentication yes
μ΄ μ€μ μ΄ μμ΄μ μ
κ·Έλ μ΄λνλ©΄μ μ κ±°λ μ€ μμλ€. μμΌλ©΄ μΆκ°ν΄μ£Όμ.
sudo synoservicectl --restart sshd # DSM6.0
sudo synosystemctl restart sshd # DSM7.0
Code language: Bash (bash)
μ΄λ κ² μ€μ νλ€λ©΄ μ μμ μΌλ‘ Synology server sshλ₯Ό keyλ₯Ό ν΅ν΄μ μ μν μ μλ€.
β λΉλ°λ²νΈ μ μ μ ν (option)
λλ ssh key μ€μ μ λΉ λ₯Έ λ‘κ·ΈμΈμ μν΄μ μ€μ ν κ²μ΄ μλλΌ λ³΄μμ μν΄μ μ€μ νλ€. κ·Έλμ μ μ€μ μΌλ‘λ λ°λ‘ λΉλ°λ²νΈλ‘ μ μν μ μκΈ° λλ¬Έμ λΉλ°λ²νΈλ‘ μ μνλ κ²μ μ ννκ³ μΆλ€.
μ΄λ»κ² μ ννλ?
sudo vim /etc/ssh/sshd_config
Code language: Bash (bash)
PasswordAuthentication no
Code language: plaintext (plaintext)
sudo synoservicectl --restart sshd # DSM6.0
sudo synosystemctl restart sshd # DSM7.0
Code language: Bash (bash)
λ³κ²½ν΄μ£Όλ©΄ λλ€.