【NOTES.0xFE】一些零碎的运维知识点

本文最后更新于:2025年9月3日 晚上

不合格的运维是这样的(恼)

0x00. 一切开始之前

在笔者的运维生涯中学到了各种各样的知识,其中不乏成体系的或是零碎的小技巧,比较成体系的知识点笔者倒是容易整合成一篇博客记录下来,但是那些零碎的不知如何分类的知识点却不好也跟着单开一篇新的博客,但似乎又没有地方存放,于是笔者选择在此处新开一篇博文,专门用来存放这些较为零碎的运维知识点,待到其中某一类积攒了足够数量之后,笔者再将之取出整合成一篇新的博客

当然,由于笔者实际上非常懒,这篇博客可能基本上不会堆太多东西(笑)

0x01. 解决 vscode 无法连接远程服务器的问题

简而言之有的时候会发现有的服务器无法使用 vscode 连接,然后报错日志大概如下,核心问题大概就是无法建立端口监听:

偷的日志,自己的忘记存了 XD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[09:54:16.562] Received install output:
listeningOn====
osReleaseId==opensuse-tumbleweed==
arch==x86_64==
vscodeArch==x64==
bitness==64==
tmpDir==/run/user/1000==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
serverStartTime==499==
execServerToken==a1aa1a11-1aaa-1111-aa11-111aa1111111==
platformDownloadPath==cli-alpine-x64==
SSH_AUTH_SOCK====
DISPLAY====
[09:54:16.562] Failed to parse remote port from server output
[09:54:16.562] Terminating local server
[09:54:16.563] Exec server for ssh-remote+test-dev-server failed: Error
[09:54:16.563] Error opening exec server for ssh-remote+test-dev-server: Error
[09:54:16.563] No hints found in the recent session.
[09:54:16.566] Local server exit: 15

在笔者所搜索到的相关报错当中,这类问题主要出现在 openSUSE 系统多一些, 唉我们大蜥蜴是真的没落了

笔者测试下来,可行的一个解决方案便是在 vscode 的 Remote.SSH 插件的设置当中, 关闭 Use Exec Server 这一项:

Reference:https://github.com/microsoft/vscode-remote-release/issues/10939

所以说这个默认开启的选项还会影响连接可用性属实是有点抽象嗷

0x02. 解决 Linux 下雷电设备连接上雷电接口后无法正常使用的问题

当你将一个纯正的雷电设备插入到一个正规的雷电接口当中是,可能会出现一个问题就是完全不能正常工作,但是在内核日志 dmesg 里又能看到这个设备插进来了:

问题在于有的时候 Thunderbolt 默认设置一个较高的安全级别(user 或 secure),默认不会对未知设备进行授权:

/sys/bus/thunderbolt/devices 下的 domain数字 表示雷电控制器,而 数字-数字 表示具体的接口

这个时候读取 sysfs 下对应路径应当能够看到 authorized0

1
2
$ cat /sys/bus/thunderbolt/devices/0-3/authorized
0

解决方案之一是对这个设备进行授权,例如:

1
$ echo 1 > /sys/bus/thunderbolt/devices/0-3/authorized

更推荐的做法是使用 FreeDesktop 提供的 bolt 工具(主流发行版仓库中应该都有,例如 Gentoo 可以使用 emerge -av sys-apps/bolt 安装),首先可以使用 boltctl list 命令查看已连接设备:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ boltctl list
● Ugreen Storage Device
├─ type: peripheral
├─ name: Ugreen Storage Device
├─ vendor: Ugreen
├─ uuid: bb030000-0082-8c1e-837f-0cdee8f1f808
├─ generation: Thunderbolt 3
├─ status: connected
│ ├─ domain: 272e8780-8026-5a49-ffff-ffffffffffff
│ ├─ rx speed: 40 Gb/s = 2 lanes * 20 Gb/s
│ ├─ tx speed: 40 Gb/s = 2 lanes * 20 Gb/s
│ └─ authflags: none
├─ connected: Wed Sep  3 09:53:37 2025
└─ stored: no
● Dell Thunderbolt 5 Dock
├─ type: peripheral
├─ name: Dell Thunderbolt 5 Dock
├─ vendor: Dell
├─ uuid: ddec8780-004b-ade9-ffff-ffffffffffff
├─ generation: USB4
├─ status: connected
│ ├─ domain: a7a30000-00ca-9b32-ffff-ffffffffffff
│ ├─ rx speed: 120 Gb/s = 3 lanes * 40 Gb/s
│ ├─ tx speed: 40 Gb/s = 1 lanes * 40 Gb/s
│ └─ authflags: none
├─ connected: Wed Sep  3 09:52:22 2025
└─ stored: no

可以看到雷电设备的 authflagsstored 都是否定的选项,下面我们使用 boltctl 根据设备的 uuid 进行临时授权:

1
$ sudo boltctl authorize bb030000-0082-8c1e-837f-0cdee8f1f808

此时应当能够看到对应的存储节点,需要注意的是其直接连接到 PCIe 通道上,因此会直接变成内置存储设备而非普通的外置 USB 存储设备,因此我们也就不能够直接移除该设备:

1
2
3
4
5
$ lspci -nn | grep -i ssd
# ...
06:00.0 Non-Volatile memory controller [0108]: Micron Technology Inc 2650 NVMe SSD (DRAM-less) [1344:5427] (rev 01)
$ sudo udisksctl power-off -b /dev/nvme2n1
Error powering off drive: No usb device (udisks-error-quark, 0)

如果要移除该设备,我们应当使用 PCIe 的那套接口,也就是 echo 1/sys/bus/pci/devices/PCI地址/remove 就能正常移除:

1
$ echo 1 | sudo tee /sys/bus/pci/devices/0000\:06\:00.0/remove

如果要永久授权,则可以使用 boltctl enroll ,例如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ boltctl enroll ddec8780-004b-ade9-ffff-ffffffffffff
● Dell Thunderbolt 5 Dock
├─ type: peripheral
├─ name: Dell Thunderbolt 5 Dock
├─ vendor: Dell
├─ uuid: ddec8780-004b-ade9-ffff-ffffffffffff
├─ dbus path: /org/freedesktop/bolt/devices/ddec8780_004b_ade9_ffff_ffffffffffff
├─ generation: USB4
├─ status: authorized
│ ├─ domain: a7a30000-00ca-9b32-ffff-ffffffffffff
│ ├─ parent: a7a30000-00ca-9b32-ffff-ffffffffffff
│ ├─ syspath: /sys/devices/pci0000:00/0000:00:1c.0/0000:3c:00.0/0000:3d:00.0/0000:3e:00.0/domain1/1-0/1-3
│ ├─ rx speed: 120 Gb/s = 3 lanes * 40 Gb/s
│ ├─ tx speed: 40 Gb/s = 1 lanes * 40 Gb/s
│ └─ authflags: none
├─ authorized: Wed Sep  3 11:23:28 2025
├─ connected: Wed Sep  3 09:52:22 2025
└─ stored: Wed Sep  3 11:23:28 2025
├─ policy: auto
└─ key: no

此外,出于方便起见,也可以在 BIOS/UEFI 配置界面当中将 Thunderbolt Security Level 修改为 No Security (SL0) ,从而做到即插即用,缺点就是会存在安全隐患:)


【NOTES.0xFE】一些零碎的运维知识点
https://arttnba3.github.io/2000/10/12/NOTE-0XFE-PIECES_OPS_KNOWLEDGE/
作者
arttnba3
发布于
2000年10月12日
许可协议