2016年5月26日 星期四

NAS learn



開啟ssh PubkeyAuthentication 服務
ref.https://www.chainsawonatireswing.com/2012/01/15/ssh-into-your-synology-diskstation-with-ssh-keys//?from=@


To start the process, you need to edit the SSH daemon’s config file to allow access via keys.

Edit/etc/ssh/sshd_config using vim & change these lines:

#RSAAuthentication yes 
#PubkeyAuthentication yes 
#AuthorizedKeysFile .ssh/authorized_keys

To this:

RSAAuthentication yes 
PubkeyAuthentication yes 
AuthorizedKeysFile .ssh/authorized_keys


Now get your permissions set correctly on that directory & file:> chmod 700 .ssh

> chmod 600 .ssh/authorized_keys

> chmod 700 .ssh/

再來是client 端 ,基本的概念就是使用private key 去開在遠端server public key

生成privatekey 和publickey
#ssh-keygen 

copy 到遠端的~/.ssh下
#scp id_rsa.pub username@serverip:~/.ssh/
登入遠端server
ssh username@serverip

將public key 加入.ssh/authorized_keys  (我的cat 曾經動過手腳 alias 成 cat -n 害我卡了一整個晚上  哭哭)
cat .ssh/id_rsa.pub >> .ssh/authorized_keys 

這樣子就可以 key 認證登入, 不需輸入密碼.


重開遠端server ssh
Restarted sshd via synoservicectl --restart sshd and by restarting whole NAS.
or
rebooot

沒有留言:

張貼留言

有敘述錯誤或者是觀念有問題歡迎指正