顯示具有 NAS 標籤的文章。 顯示所有文章
顯示具有 NAS 標籤的文章。 顯示所有文章

2018年8月28日 星期二

安裝 shadowsock server

Synology DSM6.21

#介紹
https://zh.wikipedia.org/wiki/Shadowsocks

#git位置 shadowsock python
https://github.com/dgkang/shadowsocks-python


1.先安裝 python2 or python3皆可

2.安裝 python套件包 pip  (ubuntu:apt-get install python-pip)
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
https://bootstrap.pypa.io/

3.pip 安裝 shadowsocks
pip install shadowsocks

4.
vi /etc/shadowsocks.json

{

    "local_address": "127.0.0.1",
    "local_port":1080,
    "port_password":{
    "6655":"nguguest",
    "8080":"nguguest"
    },
    "timeout":600,
    "method":"aes-256-cfb",
    "fast_open":false
}

其中
    "port_password":{
    "6655":"nguguest",
    "8080":"nguguest"
    },
是設定server port 對應的 password
這邊沒有設定serverIP 因為不需要

5.

*ssserver -c /etc/shadowsocks.json遇到error
RuntimeError: can not find library crypto 
自行修改/usr/lib/python2.7/ctypes/util.py
拿個發行版的來取代

*遇到Exception: libcrypto(OpenSSL) not found
參考https://ningselect.com/2018/05/01/synologyshadowsocks
修改 註解掉以下紅色四行
sudo vi /usr/lib/python2.7/site-packages/shadowsocks/crypto/util.py
 56     for name in lib_names:
 57         if os.name == "nt":
 58             paths.extend(find_library_nt(name))
 59 #        else:
 60 #            path = ctypes.util.find_library(name)
 61 #            if path:
 62 #                paths.append(path)

*
2020 update
最近重裝遇到另一個新error
TypeError: find_library() takes exactly 1 argument (3 given)
  File "/usr/lib/python2.7/site-packages/shadowsocks/crypto/openssl.py", line 41, in load_openssl
    raise Exception('libcrypto(OpenSSL) not found')
Exception: libcrypto(OpenSSL) not found

sudo -i 後進入root即可
ssserver -c /etc/shadowsocks.json -d start
(我直接sudo 不能,應該是lib path 的問題,沒有繼續trace)

6.連線試試 後臺啟動
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
ssserver -c /etc/shadowsocks.json -d restart


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

2016年3月30日 星期三

Synology 6.0 root passwd

DSM 在6.0有做一些修正導致無法使用root 登入(安全性考量 default ban 掉root),或者是拿不到權限

比較簡單的作法是使用管理者帳號登入然後下 (這邊加進sudo 的功能)
sudo -i
即可變成root 登入

但是還是無法直接使用root 登入,若sudo 失效系統就GG

所以還是有其他方法改成直接使用root登入如下


After getting the DSM 6.0 upgrade, I’ve become unable to login as root using SSH, even though I’ve been able to do it before the upgrade (DSM 5.5 or something like that).
The solution:
1. SSH to machine as admin user.
2. Enter command “sudo su” and providing admin password.
3. Enter command “synouser --setpw root yourPasswd “.
Now I’m able to logon as root using SSH again, and I didn’t have to mess with telnet.

這是更新的經驗是,以後synology 不要亂進大版(我從DSM5.2 -> DSM6.0),否環境可能會被改到,還要再弄一次。

/etc 下的chmod 權限不要亂改,我為了讓權限打開 修改此檔暫時將 /etc/sudoers權限改為chmod 777 ,然後就發生悲劇了,使用sudo 指令時都出現

sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

意思是任何人都可以修改此檔,系統認為此檔無效,因此sudo 不吃此檔案
想改回來需要sudo chmod 但是又先執行了sudo 引此就卡死了,然後系統又不能使用使用root登入將此檔的權限改回來,整個系統差點GG

還好在/opt/bin/ 底下我也有安裝sudo 使用此執行的改回來就正常了。

2015年3月18日 星期三

synology NAS 建立 git server


基本上DSM 說明上有教你怎麼設定

若要允許使用者使用 Git:

  1. 使用具管理權限的帳號登入 DSM。前往控制台 > 終端機並啟動 SSH 服務。
  2. 啟動 Git 套件。選擇要讓哪些使用者從 repository check in 及 check out 檔案。

注意:

Git 使用者會受到 git-shell 之限制,僅能進行與 Git 相關的活動。此登入型 shell 會套用至 Git 使用者,以確保這些帳號僅用於 Git 相關之操作。因此,Git 使用者僅能使用 SSH 連線來 push 或 pull Git repository,無法完整存取 DSM。

若要新增 Git repository:

  1. 透過 SSH 以 root 或 admin 身份登入您的 Synology 伺服器。
  2. 變更目錄至 /volumeX (X 代表儲存空間編號) 來建立資料夾。例如:「git_repos」。該資料夾的權限會與 Linux 相同。
  3. 於資料夾中執行 git init 來建立空的 repository。
  4. Repository 建立完畢後,Git 用戶端可輸入下列指令來存取此 repository:
    git clone ssh://[Git 使用者]@[您的 Synology 伺服器 IP 位址或主機名稱]/[Git repository 路徑]

照著上面設定完後就可以開心使用Git server 拉~~~  才怪