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.

33.9 KB
Raw Blame
<!doctype html>
<html lang="zh-CN">
<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/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/server/">
  <meta property="og:image" content="https://pasteferry.cc/assets/og.png">
  <meta property="og:locale" content="zh_CN">
  <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=".././" aria-label="隔空贴首页"><img src="../assets/icon.svg?v=65a69999e0" alt="" width="26" height="26">隔空贴</a>
      <nav aria-label="页面导航">
        <a href="../features/">功能</a>
        <a class="mid" href="../start/">快速开始</a>
        <a class="wide" href="../start/#server" aria-current="true">连接方式</a>
        <a href="../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="../start/">快速开始</a></li>
            <li class="narrow"><a href="../start/#server">连接方式</a></li>
            <li><a href="../themes/">主题教程</a></li>
            <li><a href="../how/">工作原理</a></li>
            <li><a href="../security/">安全与隐私</a></li>
            <li><a href="../faq/">常见问题</a></li>
            <li><a href="../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" aria-current="page">简体中文</a></li>
            <li><a href="../zh-tw/server/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</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=".././">隔空贴</a> / <a href="../start/#server">连接方式</a></p>
        <h1 class="display">在局域网里部署服务器</h1>
        <p class="lede">家里或办公室的电脑在同一个网络里,就不需要云服务器。找一台常开的电脑,下载、运行一个脚本,再把它显示的地址填进每台电脑的隔空贴里。</p>
        <p class="notice"><strong>同一个网络里,现在不需要服务器了:</strong>装好 App 直接配对就能用,见<a href="../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 静态分配」(也叫「地址保留」「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> 回车,运行 <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>(换成你的地址),按回车保存。</p></li>
          <li><h3>看连接状态</h3><p>「连接状态」变成绿色的「已连接」就好了。接着在「设备」里配对,之后复制就会同步。</p></li>
        </ol>
        <figure class="shot">
          <img src="../assets/screenshots/settings-lan-dark.png?v=c7f425b3db" width="2112" height="1472" loading="lazy" alt="隔空贴的「设置 → 连接」页:「自定义服务器」填着 ws://192.168.1.20:8787/signal,「连接状态」显示「已连接」">
        </figure>
        <p class="note">还没装 App?见<a href="../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> 结尾,填完按过回车。</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="../official/">服务</a>,或者用<a href="../cloud/">公网服务器</a>、<a href="../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="../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="../privacy/">隐私说明</a>
        <a href="../feedback/">讨论与反馈</a>
      </nav>
      <nav aria-label="语言">
        <a href="../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
        <a href="../zh-tw/server/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</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>