update some content
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
"articleSection" : "post",
|
||||
"name" : "筆記- 啟用群暉NAS (Synology NAS)的SSH Server 透過Publickey 認證免密碼登入",
|
||||
"headline" : "筆記- 啟用群暉NAS (Synology NAS)的SSH Server 透過Publickey 認證免密碼登入",
|
||||
"description" : "\x3cp\x3e公司內有幾台NAS,其中有一台用來放開發人員的postgresql dump file\n之前都是主要的開發人員上傳到google drive,分享出來 ,然後其他人去抓回來\x3c\/p\x3e\n\x3cp\x3e這樣子有個問題是,當server要存取這些檔案時,就沒辦法了,除非透過一些 3rd party的軟體\n像是這篇\x3c\/p\x3e\n\x3cp\x3e\x3ca href=\x22https:\/\/www.omgubuntu.co.uk\/2017\/04\/mount-google-drive-ocamlfuse-linux\x22\x3ehttps:\/\/www.omgubuntu.co.uk\/2017\/04\/mount-google-drive-ocamlfuse-linux\x3c\/a\x3e\x3c\/p\x3e\n\x3cp\x3e或者是這篇\x3c\/p\x3e\n\x3cp\x3e\x3ca href=\x22https:\/\/www.maketecheasier.com\/mount-google-drive-ubuntu\/\x22\x3ehttps:\/\/www.maketecheasier.com\/mount-google-drive-ubuntu\/\x3c\/a\x3e\x3c\/p\x3e\n\x3cp\x3e但是手邊的伺服器,原則上除非有必要,不然都沒有開放internet\n所以導致明明檔案就在那邊,但是要取得就是很麻煩\x3c\/p\x3e",
|
||||
"description" : "\u003cp\u003e公司內有幾台NAS,其中有一台用來放開發人員的postgresql dump file\n之前都是主要的開發人員上傳到google drive,分享出來 ,然後其他人去抓回來\u003c\/p\u003e\n\u003cp\u003e這樣子有個問題是,當server要存取這些檔案時,就沒辦法了,除非透過一些 3rd party的軟體\n像是這篇\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\u0022https:\/\/www.omgubuntu.co.uk\/2017\/04\/mount-google-drive-ocamlfuse-linux\u0022\u003ehttps:\/\/www.omgubuntu.co.uk\/2017\/04\/mount-google-drive-ocamlfuse-linux\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003e或者是這篇\u003c\/p\u003e\n\u003cp\u003e\u003ca href=\u0022https:\/\/www.maketecheasier.com\/mount-google-drive-ubuntu\/\u0022\u003ehttps:\/\/www.maketecheasier.com\/mount-google-drive-ubuntu\/\u003c\/a\u003e\u003c\/p\u003e\n\u003cp\u003e但是手邊的伺服器,原則上除非有必要,不然都沒有開放internet\n所以導致明明檔案就在那邊,但是要取得就是很麻煩\u003c\/p\u003e",
|
||||
"inLanguage" : "en",
|
||||
"author" : "Eric Chang",
|
||||
"creator" : "Eric Chang",
|
||||
@@ -21,8 +21,8 @@
|
||||
"accountablePerson" : "Eric Chang",
|
||||
"copyrightHolder" : "Eric Chang",
|
||||
"copyrightYear" : "2018",
|
||||
"datePublished": "2018-11-05 14:16:54 \x2b0800 CST",
|
||||
"dateModified" : "2018-11-05 14:16:54 \x2b0800 CST",
|
||||
"datePublished": "2018-11-05 14:16:54 \u002b0800 CST",
|
||||
"dateModified" : "2018-11-05 14:16:54 \u002b0800 CST",
|
||||
"url" : "https:\/\/h.cowbay.org\/post\/enable-synology-public-ssh\/",
|
||||
"wordCount" : "145",
|
||||
"image" : "https://h.cowbay.orghttps://i.imgur.com/jcDQmI1.png"",
|
||||
@@ -45,9 +45,9 @@
|
||||
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
||||
|
||||
<link href="https://h.cowbay.org/css/style.css?v=1632901488" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
||||
<link href="https://h.cowbay.org/css/style.css?v=1634607506" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
||||
|
||||
<link href="https://h.cowbay.org/css/custom.css?v=1632901488" rel="stylesheet" type='text/css' media='all'>
|
||||
<link href="https://h.cowbay.org/css/custom.css?v=1634607506" rel="stylesheet" type='text/css' media='all'>
|
||||
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
||||
|
||||
@@ -323,41 +323,41 @@ if (!doNotTrack) {
|
||||
<p><del>建立時,注意一下要指定家目錄路徑</del></p>
|
||||
<p>更正: 群暉的界面好像不能指定家目錄</p>
|
||||
<p>預設的路徑如下</p>
|
||||
<pre><code>eric:x:1071:100::/var/services/homes/eric:/sbin/nologin
|
||||
<pre tabindex="0"><code>eric:x:1071:100::/var/services/homes/eric:/sbin/nologin
|
||||
</code></pre><p>不過我覺得怪怪的,因為在我手邊的幾台NAS底下 /var/services/homes 都切不過去
|
||||
確認一下路徑,發現那個 <code>@fake_home_link</code> 根本就不存在啊!</p>
|
||||
<pre><code>admin@storage:/volume1$ ls -lart /var/services/homes
|
||||
<pre tabindex="0"><code>admin@storage:/volume1$ ls -lart /var/services/homes
|
||||
lrwxrwxrwx 1 root root 24 May 23 14:14 /var/services/homes -> /volume1/@fake_home_link
|
||||
admin@storage:/volume1$
|
||||
</code></pre><p>我在想是不是之前的人有改過什麼..
|
||||
anyway ,反正先不管這邊,直接修改 /etc/passwd檔案</p>
|
||||
<pre><code>sudo vim /etc/passwd
|
||||
<pre tabindex="0"><code>sudo vim /etc/passwd
|
||||
</code></pre><p>修正到正確的路徑,順便把shell 也改掉,不然不能登入</p>
|
||||
<pre><code>eric:x:1071:100::/volume1/homes/eric:/bin/sh
|
||||
<pre tabindex="0"><code>eric:x:1071:100::/volume1/homes/eric:/bin/sh
|
||||
</code></pre><h3 id="修改-etcsshsshd_config">修改 /etc/ssh/sshd_config</h3>
|
||||
<p>再來修正預設沒有啟用 Publickey 驗證的 ssh</p>
|
||||
<pre><code>sudo vim /etc/ssh/sshd_config
|
||||
<pre tabindex="0"><code>sudo vim /etc/ssh/sshd_config
|
||||
</code></pre><p>確認底下三行存在</p>
|
||||
<pre><code>RSAAuthentication yes
|
||||
<pre tabindex="0"><code>RSAAuthentication yes
|
||||
PubkeyAuthentication yes
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
||||
</code></pre><h3 id="將key傳到-nas上">將KEY傳到 NAS上</h3>
|
||||
<p>先建立相關目錄,順便修正一下目錄權限</p>
|
||||
<pre><code>chmod 755 /volume1/homes/eric
|
||||
<pre tabindex="0"><code>chmod 755 /volume1/homes/eric
|
||||
mkdir -p /volume1/homes/eric/.ssh
|
||||
chmod 700 /volume1/homes/eric/.ssh
|
||||
</code></pre><p>再來把Publickey 傳到NAS,複製貼上也好,ssh-copy-id也可以,同時修正權限</p>
|
||||
<pre><code>vim /volume1/homes/eric/.ssh/authorized_keys
|
||||
<pre tabindex="0"><code>vim /volume1/homes/eric/.ssh/authorized_keys
|
||||
chmod 0600 /volume1/eric/.ssh/authorized_keys
|
||||
</code></pre><h3 id="重啟ssh">重啟SSH</h3>
|
||||
<p>本來這個步驟應該可以用</p>
|
||||
<pre><code>synoservicectl --restart sshd
|
||||
<pre tabindex="0"><code>synoservicectl --restart sshd
|
||||
</code></pre><p>來解決
|
||||
但是實際上這個指令只會把你踢出 SSH session ….( WTF!!! )</p>
|
||||
<p>所以還是要去NAS的管理界面,去關閉再打開SSH (有點蠢..)
|
||||
<img src="https://i.imgur.com/jcDQmI1.png" alt="Synology WEB UI"></p>
|
||||
<p>然後就可以測試用Publickey 來登入NAS了</p>
|
||||
<pre><code>2018-11-05 14:47:12 [mini@s009 ansiblecontrol]$ ssh admin@storage
|
||||
<pre tabindex="0"><code>2018-11-05 14:47:12 [mini@s009 ansiblecontrol]$ ssh admin@storage
|
||||
admin@storage:~$
|
||||
</code></pre><p>確認免密碼登入無誤了!</p>
|
||||
</article>
|
||||
@@ -652,7 +652,7 @@ title="pinterest icon"></i>
|
||||
</div>
|
||||
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
|
||||
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
|
||||
<script src="https://h.cowbay.org/js/production.min.js?v=1632901488"></script>
|
||||
<script src="https://h.cowbay.org/js/production.min.js?v=1634607506"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user