Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

34.5 KB
Raw Blame
<!doctype html>
<html lang="zh-TW">
<head>
  <meta charset="utf-8">
  <script>
    (function () {
      if (location.hostname !== "baiyuze.github.io") return;
      var prefix = /^\/(?:pasteferry|copysync)(?=\/|$)/.exec(location.pathname);
      if (!prefix) return;
      var path = location.pathname.slice(prefix[0].length) || "/";
      location.replace("https://pasteferry.cc" + path + location.search + location.hash);
    })();
  </script>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>在區域網路裡架設隔空貼伺服器:Windows、Mac、Linux 教學</title>
  <meta name="description" content="兩台電腦在同一個網路裡時,不需要雲端伺服器:在一台常開的 Windows、Mac 或 Linux 電腦上執行隔空貼的信令與 TURN 伺服器,下載後執行一個腳本即可,開機自動執行。附用戶端設定與疑難排解。">
  <link rel="canonical" href="https://pasteferry.cc/zh-tw/server/">
  <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/server/">
  <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/server/">
  <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/server/">
  <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/server/">
  <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/server/">
  <meta name="theme-color" content="#141416">
  <meta property="og:type" content="article">
  <meta property="og:site_name" content="隔空貼">
  <meta property="og:title" content="在區域網路裡架設隔空貼伺服器:Windows、Mac、Linux 教學">
  <meta property="og:description" content="兩台電腦在同一個網路裡時,不需要雲端伺服器:在一台常開的 Windows、Mac 或 Linux 電腦上執行隔空貼的信令與 TURN 伺服器,下載後執行一個腳本即可,開機自動執行。附用戶端設定與疑難排解。">
  <meta property="og:url" content="https://pasteferry.cc/zh-tw/server/">
  <meta property="og:image" content="https://pasteferry.cc/assets/og-zh-hant.png">
  <meta property="og:locale" content="zh_TW">
  <meta name="twitter:card" content="summary_large_image">
  <link rel="icon" href="../../assets/favicon.svg?v=df696024d8" type="image/svg+xml">
  <link rel="icon" href="../../assets/favicon-32.png?v=8e9afa506d" sizes="32x32" type="image/png">
  <link rel="apple-touch-icon" href="../../assets/apple-touch-icon.png?v=bcbf406cb8">
  <link rel="stylesheet" href="../../assets/site.css?v=dbae55d27c">
  <script>document.documentElement.classList.add("js");if (!/Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent)) document.documentElement.classList.add("pc");</script>
</head>
<body>
  <a class="skip" href="#main">跳到主要內容</a>

  <header class="bar">
    <div class="wrap">
      <a class="brand" href="../../zh-tw/" aria-label="隔空貼首頁"><img src="../../assets/icon.svg?v=65a69999e0" alt="" width="26" height="26">隔空貼</a>
      <nav aria-label="頁面導覽">
        <a href="../../zh-tw/features/">功能</a>
        <a class="mid" href="../../zh-tw/start/">快速入門</a>
        <a class="wide" href="../../zh-tw/start/#server" aria-current="true">連線方式</a>
        <a href="../../zh-tw/download/">下載</a>
        <details class="menu">
          <summary aria-label="更多頁面"><span>更多</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
          <ul>
            <li class="narrow"><a href="../../zh-tw/start/">快速入門</a></li>
            <li class="narrow"><a href="../../zh-tw/start/#server">連線方式</a></li>
            <li><a href="../../zh-tw/themes/">主題教學</a></li>
            <li><a href="../../zh-tw/how/">運作原理</a></li>
            <li><a href="../../zh-tw/security/">安全與隱私</a></li>
            <li><a href="../../zh-tw/faq/">常見問題</a></li>
            <li><a href="../../zh-tw/feedback/">討論與回饋</a></li>
            <li class="sep" role="separator"></li>
            <li><a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新記錄</a></li>
            <li class="narrow-gh"><a href="https://github.com/baiyuze/pasteferry">GitHub</a></li>
          </ul>
        </details>
        <a class="gh" href="https://github.com/baiyuze/pasteferry" data-gh-stars aria-label="在 GitHub 上給隔空貼點 Star"><svg class="gh-mark" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg><span class="gh-label">Star</span><span class="gh-count" hidden><svg class="gh-star" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.751.751 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"/></svg><b></b></span></a>
        <details class="lang">
          <summary aria-label="語言:繁體中文(台灣)"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>繁體中文(台灣)</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
          <ul>
            <li><a href="../../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a></li>
            <li><a href="../../zh-tw/server/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw" aria-current="page">繁體中文(台灣)</a></li>
            <li><a href="../../zh-hk/server/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a></li>
            <li><a href="../../en/server/" hreflang="en" lang="en" data-lang="en">English</a></li>
            <li><a href="../../ja/server/" hreflang="ja" lang="ja" data-lang="ja">日本語</a></li>
          </ul>
        </details>
      </nav>
    </div>
  </header>

  <main id="main">
    <section class="hero guide-hero">
      <div class="wrap">
        <p class="crumb"><a href="../../zh-tw/">隔空貼</a> / <a href="../../zh-tw/start/#server">連線方式</a></p>
        <h1 class="display">在區域網路裡架設伺服器</h1>
        <p class="lede">家裡或辦公室的電腦在同一個網路裡,就不需要雲端伺服器。找一台常開的電腦,下載並執行一個腳本,再把它顯示的位址填進每台電腦的隔空貼裡。</p>
        <p class="notice"><strong>在同一個網路裡,現在已經不需要伺服器了:</strong>裝好 App 直接配對就能用,見<a href="../../zh-tw/lan/">同一網路教學</a>。這篇仍然適用於兩個網段之間互相連不到、需要經過一台兩邊都連得到的電腦中繼的情況。</p>
        <ol class="guide-toc">
          <li><a href="#prepare">準備</a></li>
          <li><a href="#install">安裝伺服器</a></li>
          <li><a href="#check">檢查</a></li>
          <li><a href="#clients">填位址</a></li>
          <li><a href="#faq">常見問題</a></li>
        </ol>
      </div>
    </section>

    <section class="section" id="overview" aria-labelledby="overview-title">
      <div class="wrap">
        <h2 id="overview-title">伺服器只負責牽線</h2>
        <p class="intro">每台電腦都一直連著伺服器,靠它找到對方、交換連線資訊。連上之後,複製的內容在兩台電腦之間直接傳輸;只有直連打不通時,才經過它中繼,內容依然加密。</p>
        <figure class="diagram">
          <svg viewBox="0 0 960 440" role="img" aria-labelledby="lan-title lan-desc">
            <title id="lan-title">區域網路裡的隔空貼</title>
            <desc id="lan-desc">在同一個區域網路裡,Mac 與 Windows 電腦透過信令連線到位址為 192.168.1.20 的伺服器,複製的內容在兩台電腦之間直連傳輸;直連不通時經伺服器的 TURN 中繼。</desc>
            <rect class="d-lan" x="8" y="8" width="944" height="384" rx="22"/>
            <text class="d-lan-label" x="32" y="42">區域網路:同一個 Wi‑Fi 或有線網路</text>
            <rect class="d-box" x="340" y="64" width="280" height="104" rx="14"/>
            <text class="d-title" x="480" y="106" text-anchor="middle">伺服器</text>
            <text class="d-ip" x="480" y="138" text-anchor="middle">192.168.1.20</text>
            <path class="d-sig" d="M150 250V96H340"/>
            <path class="d-sig" d="M810 250V96H620"/>
            <path class="d-relay" d="M206 250V140H340"/>
            <path class="d-relay" d="M754 250V140H620"/>
            <text class="d-note" x="164" y="86">信令 TCP 8787</text>
            <text class="d-note" x="220" y="200">中繼 UDP 3478,直連不通時</text>
            <rect class="d-box" x="40" y="250" width="240" height="112" rx="14"/>
            <text class="d-title" x="160" y="300" text-anchor="middle">Mac</text>
            <text class="d-sub" x="160" y="328" text-anchor="middle">已安裝隔空貼</text>
            <rect class="d-box" x="680" y="250" width="240" height="112" rx="14"/>
            <text class="d-title" x="800" y="300" text-anchor="middle">Windows</text>
            <text class="d-sub" x="800" y="328" text-anchor="middle">已安裝隔空貼</text>
            <path class="d-direct" d="M280 306H680"/>
            <text class="d-label" x="480" y="292" text-anchor="middle">直連,端對端加密</text>
            <text class="d-note" x="480" y="336" text-anchor="middle">複製的內容只在兩台電腦之間傳輸</text>
            <g class="d-legend" transform="translate(40 424)">
              <path class="d-direct" d="M0 0H28"/><text x="38" y="5">資料(直連)</text>
              <path class="d-relay" d="M250 0H278"/><text x="288" y="5">資料(中繼,備用)</text>
              <path class="d-sig" d="M560 0H588"/><text x="598" y="5">信令</text>
            </g>
          </svg>
        </figure>
        <ul class="points ports">
          <li><strong>信令,TCP 8787。</strong>每台電腦都一直連著它,用來發現對方、配對、交換連線資訊。</li>
          <li><strong>直連。</strong>在同一個區域網路裡,內容幾乎總是在兩台電腦之間直接傳輸,速度就是區域網路的速度。</li>
          <li><strong>中繼,UDP 3478。</strong>只有在訪客網路、開了 AP 隔離的 Wi‑Fi、不同網段之間互相連不到時才會用到。</li>
        </ul>
      </div>
    </section>

    <section class="section" id="prepare" aria-labelledby="prepare-title">
      <div class="wrap">
        <h2 id="prepare-title">開始之前</h2>
        <dl class="fallbacks">
          <div><dt>一台常開的電腦</dt><dd>Windows 10、11,macOS 13 以上,或任何 Linux 都可以,用兩台電腦中的其中一台也行。它關機或睡眠時同步會暫停,醒來後自動恢復。NAS、軟路由、Mac mini 這類一直開著的裝置最適合,記憶體只佔約 15 MB。</dd></div>
          <div><dt>一個固定的位址</dt><dd>在路由器的「DHCP 靜態分配」(也叫「DHCP 保留」「IP 與 MAC 綁定」)裡幫這台電腦固定一個位址。不然路由器換了位址,每台電腦都要重新填。</dd></div>
          <div><dt>在同一個網路裡</dt><dd>裝置連同一個 Wi‑Fi 或有線網路就行。訪客網路、開了「AP 隔離」的 Wi‑Fi 不讓裝置互相連線,需要換個網路或關掉隔離。</dd></div>
          <div><dt>離開這個網路就不會同步</dt><dd>伺服器只在區域網路裡連得到,筆電帶出門後,要回來才會繼續同步。</dd></div>
        </dl>
      </div>
    </section>

    <section class="section" id="install" aria-labelledby="install-title">
      <div class="wrap">
        <h2 id="install-title">安裝伺服器</h2>
        <p class="intro">選擇伺服器所在電腦的系統。安裝腳本會自動找出本機的區域網路位址,把伺服器設成開機自動執行,最後顯示用戶端要填的位址。</p>
        <div class="os-tabs" data-tabs="os">
          <div class="tablist" role="tablist" aria-label="伺服器所在電腦的系統" hidden>
            <button type="button" role="tab" id="tab-windows" aria-controls="windows">Windows</button>
            <button type="button" role="tab" id="tab-macos" aria-controls="macos">macOS</button>
            <button type="button" role="tab" id="tab-linux" aria-controls="linux">Linux</button>
          </div>

          <section class="os" id="windows" role="tabpanel" aria-labelledby="tab-windows">
            <h3 class="os-title"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="1.5"/><path d="M9 20h6M12 16v4"/></svg>Windows</h3>
            <div class="os-grid">
              <div class="os-steps">
                <ol class="steps">
                <li>下載 <a href="https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-windows-amd64.zip">pasteferry-server-windows-amd64.zip</a>,按右鍵選「解壓縮全部」。</li>
                <li>打開解壓縮後的資料夾,按兩下 <code>install.cmd</code>。<span class="aside">出現「Windows 已保護您的電腦」時,點「其他資訊」,再點「仍要執行」;跳出「使用者帳戶控制」時點「是」。伺服器還沒有程式碼簽章,所以會詢問這一次。</span></li>
                <li>安裝會在新開的視窗裡進行。最後顯示的 <code>ws://…/signal</code> 就是用戶端要填的位址。</li>
                </ol>
                <a class="button" href="https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-windows-amd64.zip"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>下載 Windows 版伺服器</a>
                <p class="small">在中國大陸的伺服器從 GitHub 下載很慢的話,可以改從 Gitee 鏡像下載:<a href="https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-windows-amd64.zip">https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-windows-amd64.zip</a></p>
                <ul class="points">
                <li><strong>以 Windows 服務執行:</strong>開機就啟動,不用登入,也沒有視窗。在「服務」裡的名稱是 PasteFerry Server。</li>
                <li><strong>防火牆已經開放:</strong>腳本新增了一條只針對 pasteferry-server.exe 的輸入規則,不用自己開連接埠。</li>
                <li><strong>位址抓錯了</strong>(例如裝了虛擬機或 VPN,有好幾張網路卡):在解壓縮後資料夾的網址列輸入 <code>cmd</code> 再按 Enter,執行 <code>install.cmd 192.168.1.20</code>,換成你的位址。</li>
                <li>支援 Windows 10、11,x64。</li>
                </ul>
              </div>
              <div class="os-figures">
                <figure class="explorer" role="img" aria-label="解壓縮後的資料夾裡有 pasteferry-server.exe、install.cmd、install.ps1、README.md、uninstall.cmd,按兩下其中的 install.cmd">
                  <div class="t-bar win"><span class="t-tab folder">pasteferry-server-windows-amd64</span><span class="t-ctl" aria-hidden="true"><i></i><i></i><i></i></span></div>
                  <ul class="files">
                  <li><span class="f-icon exe" aria-hidden="true"></span><span class="f-name">pasteferry-server.exe</span></li>
                  <li class="hl"><span class="f-icon cmd" aria-hidden="true"></span><span class="f-name">install.cmd</span><em>按兩下</em></li>
                  <li><span class="f-icon doc" aria-hidden="true"></span><span class="f-name">install.ps1</span></li>
                  <li><span class="f-icon doc" aria-hidden="true"></span><span class="f-name">README.md</span></li>
                  <li><span class="f-icon cmd" aria-hidden="true"></span><span class="f-name">uninstall.cmd</span></li>
                  </ul>
                </figure>
                <figure class="term" role="img" aria-label="install.cmd 執行完的視窗:依序停止舊版本、安裝、註冊服務、開放防火牆、啟動,最後顯示用戶端要填的位址 ws://192.168.1.20:8787/signal">
                <div class="t-bar win"><span class="t-tab"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3 5.5 10.5 4.5v7H3zM11.5 4.4 21 3v8.5h-9.5zM3 12.5h7.5v7L3 18.5zM11.5 12.5H21V21l-9.5-1.4z"/></svg>系統管理員: Windows PowerShell</span><span class="t-ctl" aria-hidden="true"><i></i><i></i><i></i></span></div>
<pre class="t-body"><span class="t-step">&gt; 停止旧版本</span>
<span class="t-step">&gt; 安装到 C:\Program Files\PasteFerry Server</span>
<span class="t-step">&gt; 注册服务 PasteFerryServer(中转地址 192.168.1.20)</span>
<span class="t-step">&gt; 在 Windows 防火墙里放行</span>
<span class="t-step">&gt; 启动</span>
  √ 已启动

安装完成:pasteferry-server 2.10.1,作为 Windows 服务开机自动运行
在每台电脑的 PasteFerry「设置 → 连接 → 自定义服务器」填:

    <span class="t-url">ws://192.168.1.20:8787/signal</span>

  程序   C:\Program Files\PasteFerry Server
  日志   C:\ProgramData\PasteFerry Server\server.log
  重启   Restart-Service PasteFerryServer(管理员 PowerShell)
  卸载   双击 uninstall.cmd</pre>
              </figure>
              </div>
            </div>
            <div class="table-scroll">
                <table class="manage">
                  <caption>之後會用到的</caption>
                  <tbody>
                  <tr><th scope="row">狀態</th><td>在系統管理員 PowerShell 裡執行 <code>Get-Service PasteFerryServer</code>,或在「服務」裡找 PasteFerry Server</td></tr>
                  <tr><th scope="row">記錄檔</th><td><code>C:\ProgramData\PasteFerry Server\server.log</code></td></tr>
                  <tr><th scope="row">重新啟動</th><td>在系統管理員 PowerShell 裡執行 <code>Restart-Service PasteFerryServer</code></td></tr>
                  <tr><th scope="row">升級</th><td>下載新版本,解壓縮後再按兩下 <code>install.cmd</code>,原本的設定會保留</td></tr>
                  <tr><th scope="row">解除安裝</th><td>按兩下 <code>uninstall.cmd</code>,服務、防火牆規則和檔案會一併刪除</td></tr>
                  </tbody>
                </table>
              </div>
          </section>

          <section class="os" id="macos" role="tabpanel" aria-labelledby="tab-macos">
            <h3 class="os-title"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="5" width="16" height="11" rx="1.5"/><path d="M2 19h20"/></svg>macOS</h3>
            <div class="os-grid">
              <div class="os-steps">
                <ol class="steps">
                  <li>打開「終端機」,逐行執行:
                <div class="code">
                  <button class="copy" type="button" data-done="已複製">複製</button>
<pre><code>curl -LO https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-macos.tar.gz
tar xzf pasteferry-server-macos.tar.gz
cd pasteferry-server-macos
./install.sh</code></pre>
                </div>
                <p class="small">在中國大陸的伺服器從 GitHub 下載很慢的話,可以改從 Gitee 鏡像下載:<a href="https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-macos.tar.gz">https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-macos.tar.gz</a></p></li>
                <li>最後顯示的 <code>ws://…/signal</code> 就是用戶端要填的位址。</li>
                </ol>
                <ul class="points">
                <li><strong>不需要管理者權限。</strong>登入這台 Mac 後會自動在背景執行,意外結束時會被系統重新啟動。</li>
                <li><strong>這台 Mac 不能進入睡眠:</strong>在「系統設定 → 能源」(筆電在「電池 → 選項」)裡開啟防止自動進入睡眠的選項。</li>
                <li><strong>開著系統防火牆的話,</strong>腳本最後會給出開放 pasteferry-server 的指令。</li>
                <li>Intel 與 Apple 晶片通用,macOS 13 以上。</li>
                </ul>
              </div>
              <div class="os-figures">
                <figure class="term" role="img" aria-label="在終端機裡執行 ./install.sh 的輸出:安裝、寫入 LaunchAgent、啟動,最後顯示用戶端要填的位址 ws://192.168.1.20:8787/signal">
                <div class="t-bar mac"><span class="t-lights" aria-hidden="true"><i></i><i></i><i></i></span><span class="t-title">pasteferry-server-macos — zsh</span></div>
<pre class="t-body"><span class="t-prompt">%</span> ./install.sh
<span class="t-step">▶ 停止旧版本</span>
<span class="t-step">▶ 安装到 /Users/me/Library/Application Support/PasteFerry Server</span>
<span class="t-step">▶ 写入 LaunchAgent(中转地址 192.168.1.20)</span>
<span class="t-step">▶ 启动</span>
  ✓ 已启动

安装完成:pasteferry-server 2.10.1,登录这台 Mac 后自动运行
在每台电脑的 PasteFerry「设置 → 连接 → 自定义服务器」填:

    <span class="t-url">ws://192.168.1.20:8787/signal</span>

  日志   /Users/me/Library/Logs/PasteFerry/server.log
  重启   launchctl kickstart -k gui/501/com.pasteferry.server
  卸载   ./install.sh uninstall</pre>
              </figure>
              </div>
            </div>
            <div class="table-scroll">
                <table class="manage">
                  <caption>之後會用到的</caption>
                  <tbody>
                  <tr><th scope="row">記錄檔</th><td><code>~/Library/Logs/PasteFerry/server.log</code></td></tr>
                  <tr><th scope="row">重新啟動</th><td><code>launchctl kickstart -k gui/$(id -u)/com.pasteferry.server</code></td></tr>
                  <tr><th scope="row">升級</th><td>下載新版本,解壓縮後再執行 <code>./install.sh</code>,原本的設定會保留</td></tr>
                  <tr><th scope="row">解除安裝</th><td><code>./install.sh uninstall</code></td></tr>
                  </tbody>
                </table>
              </div>
          </section>

          <section class="os" id="linux" role="tabpanel" aria-labelledby="tab-linux">
            <h3 class="os-title"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="4" width="16" height="7" rx="1.5"/><rect x="4" y="13" width="16" height="7" rx="1.5"/><path d="M8 7.5h.01M8 16.5h.01"/></svg>Linux</h3>
            <div class="os-grid">
              <div class="os-steps">
                <ol class="steps">
                  <li>在這台機器上(或用 ssh 登入後)逐行執行:<span class="aside">ARM 裝置,例如裝了 64 位元系統的樹莓派,把 <code>amd64</code> 換成 <code>arm64</code>。</span>
                <div class="code">
                  <button class="copy" type="button" data-done="已複製">複製</button>
<pre><code>curl -LO https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-linux-amd64.tar.gz
tar xzf pasteferry-server-linux-amd64.tar.gz
cd pasteferry-server-linux-amd64
sudo ./install.sh</code></pre>
                </div>
                <p class="small">在中國大陸的伺服器從 GitHub 下載很慢的話,可以改從 Gitee 鏡像下載:<a href="https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-linux-amd64.tar.gz">https://gitee.com/baiyuze/pasteferry/releases/download/v2.10.1/pasteferry-server-linux-amd64.tar.gz</a></p></li>
                <li>最後顯示的 <code>ws://…/signal</code> 就是用戶端要填的位址。</li>
                </ol>
                <ul class="points">
                <li><strong>註冊為 systemd 服務,</strong>開機自動執行。需要 root。</li>
                <li><strong>開著 ufw 或 firewalld 的話,</strong>腳本最後會給出開放連接埠的指令。</li>
                <li><strong>也可以用 Docker:</strong>把 <code>env.example</code> 複製為 <code>.env</code>,<code>TURN_IP</code> 填這台機器的區域網路位址,再執行 <code>docker compose up -d</code>。必須使用 host 網路模式,所以只適用於 Linux。</li>
                </ul>
              </div>
              <div class="os-figures">
                <figure class="term" role="img" aria-label="執行 sudo ./install.sh 的輸出:安裝、寫入 systemd 單元、產生設定檔、啟動,最後顯示用戶端要填的位址 ws://192.168.1.20:8787/signal">
                <div class="t-bar mac"><span class="t-lights" aria-hidden="true"><i></i><i></i><i></i></span><span class="t-title">ssh 192.168.1.20</span></div>
<pre class="t-body"><span class="t-prompt">$</span> sudo ./install.sh
<span class="t-step">▶ 安装二进制到 /usr/local/bin</span>
<span class="t-step">▶ 写入 systemd 单元</span>
<span class="t-step">▶ 生成配置 /etc/pasteferry/server.env(中转地址 192.168.1.20)</span>
<span class="t-step">▶ 启动</span>
  ✓ 已启动

安装完成:pasteferry-server 2.10.1
在每台电脑的 PasteFerry「设置 → 连接 → 自定义服务器」填:

    <span class="t-url">ws://192.168.1.20:8787/signal</span>

  配置   /etc/pasteferry/server.env
  日志   journalctl -u pasteferry-server -f
  重启   systemctl restart pasteferry-server
  卸载   sudo ./install.sh uninstall

防火墙需放行:TCP 8787(信令)、UDP 3478(STUN 与 TURN)、UDP 32768-60999(中转端口,系统随机分配)</pre>
              </figure>
              </div>
            </div>
            <div class="table-scroll">
                <table class="manage">
                  <caption>之後會用到的</caption>
                  <tbody>
                  <tr><th scope="row">狀態</th><td><code>systemctl status pasteferry-server</code></td></tr>
                  <tr><th scope="row">記錄檔</th><td><code>journalctl -u pasteferry-server -f</code></td></tr>
                  <tr><th scope="row">重新啟動</th><td><code>sudo systemctl restart pasteferry-server</code></td></tr>
                  <tr><th scope="row">設定</th><td><code>/etc/pasteferry/server.env</code>,改完要重新啟動服務</td></tr>
                  <tr><th scope="row">升級</th><td>下載新版本,解壓縮後再執行 <code>sudo ./install.sh</code>,原本的設定會保留</td></tr>
                  <tr><th scope="row">解除安裝</th><td><code>sudo ./install.sh uninstall</code></td></tr>
                  </tbody>
                </table>
              </div>
          </section>


        </div>
      </div>
    </section>

    <section class="section" id="check" aria-labelledby="check-title">
      <div class="wrap">
        <h2 id="check-title">檢查其他電腦能不能連到它</h2>
        <p class="intro">在另一台電腦的瀏覽器裡打開 <code>http://192.168.1.20:8787/healthz</code>(換成你的位址),看到下面這一行,網路就是通的。</p>
        <figure class="browser" role="img" aria-label="用瀏覽器打開 http://192.168.1.20:8787/healthz,頁面顯示伺服器的狀態 ok 與版本號碼">
          <div class="b-bar"><span class="t-lights" aria-hidden="true"><i></i><i></i><i></i></span><span class="b-url">http://192.168.1.20:8787/healthz</span></div>
          <pre class="b-body">{"status":"ok","version":"2.10.1"}</pre>
        </figure>
        <p class="note">打不開的話,請看下面的<a href="#faq">常見問題</a>。</p>
      </div>
    </section>

    <section class="section" id="clients" aria-labelledby="clients-title">
      <div class="wrap">
        <h2 id="clients-title">在每台電腦上填位址</h2>
        <ol class="flow">
          <li><h3>打開設定</h3><p>在每台電腦上打開隔空貼,進入「設定 → 連線」。伺服器所在的那台電腦也一樣。</p></li>
          <li><h3>填入位址</h3><p>在「自訂伺服器」裡填 <code>ws://192.168.1.20:8787/signal</code>(換成你的位址),按 Enter 儲存。</p></li>
          <li><h3>查看連線狀態</h3><p>「連線狀態」變成綠色的「已連線」就完成了。接著在「裝置」裡配對,之後複製就會同步。</p></li>
        </ol>
        <figure class="shot">
          <img src="../../assets/screenshots/zh-tw/settings-lan-dark.png?v=60a79fdb00" width="2112" height="1472" loading="lazy" alt="隔空貼的「設定 → 連線」頁:「自訂伺服器」填著 ws://192.168.1.20:8787/signal,「連線狀態」顯示「已連線」">
        </figure>
        <p class="note">還沒裝 App?見<a href="../../zh-tw/start/">快速入門</a>。</p>
      </div>
    </section>

    <section class="section" id="faq" aria-labelledby="faq-title">
      <div class="wrap">
        <h2 id="faq-title">常見問題</h2>
        <div class="faq">
          <details>
            <summary>連接狀態一直是「未連線」?</summary>
            <div class="answer"><p>先核對位址:以 <code>ws://</code> 開頭,連接埠是 8787,以 <code>/signal</code> 結尾,填完有按 Enter。</p><p>再用這台電腦的瀏覽器打開 <code>http://伺服器位址:8787/healthz</code>。打不開,代表到伺服器的網路不通:伺服器沒有在執行、那台電腦進入睡眠了、被防火牆擋住了,或是它的位址變了。</p><p>Windows 的安裝腳本已經開放了防火牆;Mac 開著系統防火牆時,請執行安裝腳本最後給出的開放指令;Linux 上的 ufw、firewalld 也一樣。</p></div>
          </details>
          <details>
            <summary>裝置之間顯示「中繼」,不是「直連」?</summary>
            <div class="answer"><p>在同一個區域網路裡一般都是直連。顯示「中繼」,代表兩台電腦之間的 UDP 不通,常見於訪客網路、開了 AP 隔離的 Wi‑Fi,或兩台電腦在不同網段、中間有防火牆。中繼會經過伺服器,內容同樣加密,只是速度受那台電腦的網路限制。</p></div>
          </details>
          <details>
            <summary>伺服器的位址變了怎麼辦?</summary>
            <div class="answer"><p>帶上新位址再執行一次安裝腳本:Windows 上是 <code>install.cmd 新位址</code>,Mac 上是 <code>./install.sh 新位址</code>;Linux 上編輯 <code>/etc/pasteferry/server.env</code> 裡的 <code>-turn-ip</code>,再重新啟動服務。然後在每台電腦上改掉伺服器位址。</p><p>在路由器裡幫它固定一個位址,就不會再遇到這種事。</p></div>
          </details>
          <details>
            <summary>離開區域網路以後還能同步嗎?</summary>
            <div class="answer"><p>不能,伺服器只在區域網路裡連得到。要跨網路同步,開啟<a href="../../zh-tw/official/">服務</a>,或用<a href="../../zh-tw/cloud/">雲端伺服器</a>、<a href="../../zh-tw/tailscale/">Tailscale</a>。</p></div>
          </details>
          <details>
            <summary>伺服器所在的那台電腦也要用隔空貼,位址要填什麼?</summary>
            <div class="answer"><p>填同樣的區域網路位址就行,填 <code>ws://127.0.0.1:8787/signal</code> 也可以。伺服器和 App 互不影響。</p></div>
          </details>
        </div>
      </div>
    </section>

    <section class="closing" aria-labelledby="closing-title">
      <div class="wrap">
        <h2 class="display" id="closing-title">一台常開的電腦,就夠了。</h2>
        <div class="cta">
          <a class="button" href="../../zh-tw/download/"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>下載隔空貼</a>
        </div>
        <p class="note">版本 2.10.1,免費開源。macOS 13 以上;Windows 10、11;Linux(x64 與 ARM64)。 支援安卓 9 以上;手機可掃碼使用網頁。</p>
        <a class="source" href="https://github.com/baiyuze/pasteferry/blob/main/server/deploy/README.md">伺服器的完整架設說明(含雲端主機與 Docker)</a>
      </div>
    </section>
  </main>

  <footer class="footer">
    <div class="wrap">
      <p>隔空貼以 GNU AGPL-3.0 授權開源。</p>
      <nav aria-label="頁尾連結">
        <a href="https://github.com/baiyuze/pasteferry/releases">所有版本</a>
        <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新記錄</a>
        <a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
        <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
        <a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
        <a href="../../zh-tw/privacy/">隱私權說明</a>
        <a href="../../zh-tw/feedback/">討論與回饋</a>
      </nav>
      <nav aria-label="語言">
        <a href="../../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
        <a href="../../zh-tw/server/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw" aria-current="page">繁體中文(台灣)</a>
        <a href="../../zh-hk/server/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a>
        <a href="../../en/server/" hreflang="en" lang="en" data-lang="en">English</a>
        <a href="../../ja/server/" hreflang="ja" lang="ja" data-lang="ja">日本語</a>
      </nav>
    </div>
  </footer>

  <script src="../../assets/site.js?v=fb60f6e5ce" defer></script>
  <script src="/assets/analytics.js?v=e2777f714d" defer></script>
  <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
</body>
</html>