VSCode Remote-ssh 远程连接Kylin OS问题排查

news/2025/2/27 14:59:51/文章来源:https://www.cnblogs.com/Jeffxu/p/18740971

通过 VSCode 的 Remote-ssh 去连接Kylin操作系统时,报错 Failed to set up dynamic port forwarding connection over SSH to the VS Code Server.。 无法通过VSCode sever的SSH进行动态端口转发。
此时根据Log信息已经设置了 AllowTcpForwarding yes,并重启服务后依旧报错。
主要原因是sshd_config中的参数设置,让端口转发被禁用,因此需要对其进行设置。


1、编辑 sshd_config 中的对应参数

# 打开ssh配置文件,需要root权限
sudo vim /etc/ssh/sshd_config

设置配置中的关键参数如下:


AllowAgentForwarding yes
AllowTcpForwarding yes   # 允许端口转发
GatewayPorts yes
X11Forwarding yes# 允许通道打开
PermitTunnel yes# 当设置打开许可 PermitOpen none,这会禁用所有端口的转发,需要将其注释掉,否则会导致端口转发无法启动
#PermitOpen none

2、重启ssh服务,以让刚刚的修改生效

sudo systemctl restart sshd

【注】完整的 sshd_config 内容如下

Include /etc/ssh/sshd_config.d/*.confPort 22
Port 42717
#AddressFamily any
ListenAddress 0.0.0.0
#ListenAddress ::#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default none# Logging
#SyslogFacility AUTH
#LogLevel INFO# Authentication:#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10PubkeyAuthentication yes# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yesAllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
PermitTunnel yes
#ChrootDirectory none
#VersionAddendum none# no default banner path
Banner /etc/issue.net# Allow client to pass locale environment variables
AcceptEnv LANG LC_*# override default of no subsystems
Subsystem       sftp    /usr/lib/openssh/sftp-server# Example of overriding settings on a per-user basis
#Match User anoncvsX11Forwarding yesAllowTcpForwarding yes
#       PermitTTY no
#       ForceCommand cvs server
#PermitOpen none

【参考资料】
银河麒麟 SSH Vscode连接

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/890642.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

浅析Golang的内存管理(下篇):go垃圾回收机制

文章目录三色标记算法 混合写屏障 并发、增量回收机制 GC触发时机go语言作为内存托管类型的开发语言,go runtime提供了自动的内存管理机制,无需程序员手动管理对象的内存释放,go runtime会在合适的时机自动释放不需要的内存对象。 一、三色标记算法传统的内存对象标记算法早…

linux怎么判断服务器的cpu架构

在部署应用程序和服务时,确认服务器的CPU架构是非常重要的,因为这会直接影响软件的兼容性和性能。在Linux系统中,有许多方法可以获取服务器的CPU架构信息。本篇文章将介绍几种常用的方法,并提供代码示例,帮助用户有效地获取这个信息。 1. CPU架构的概念 CPU架构是指中央处…

vscode中不同项目使用不用的nodejs版本

只需要在vscode中当前项目里面增加一个设置

低代码在项目管理中的5大实战案例:不懂代码也能快速搭建系统!

作为项目管理领域的“老司机”,我见过太多团队因传统开发效率低、需求响应慢而错失机会。低代码平台的崛起,让业务人员也能快速搭建系统,大幅缩短交付周期。以下是5个典型场景的实践案例,用最通俗的语言讲透核心逻辑👇案例1:3天上线CRM系统(客户关系管理) 背景:某销售…

[字符串算法]Manacher

我将永远追随六花的脚步1.前置知识 回文子串  回文的子串 最长回文子串  字符串中最长的回文子串 回文半径  设以\(i\)为中心的最大回文子串的长度为\(n\),则这个字符串第\(i\)位的回文半径为\((n+1)/2\) 2.算法流程 2.1 预处理 在处理回文子串(马拉车算法适用)的问题时…

[数据结构]树

我最喜欢六花了树(基础) 1 定义 1.1 树是什么 树是一种数据结构,因为形似倒着的树而得名. 树是一种特殊图 1.2 树的定义 递归定义 1.2.1 有根树的定义 形象化的,如图1,有根树存在根节点这一定义,从根节点可以分出任意个分支,这任意个分支又可以继续细分,分出的节点称…

StrokesPlus【电脑鼠标键盘手势软件】v0.5.8.0 中文绿色便携版

点击上方蓝字关注我 前言 StrokesPlus.net是一个超方便的手势识别软件,它能帮你用手势来代替鼠标和键盘操作。用起来既简单又灵活,功能还特别强大。 操作起来非常简单,它有好多实用的功能,比如智能识别你写的字、设定手势操作的区域、模拟鼠标的各种动作、运行脚本、响应窗…

大模型推理主战场:什么才是通信协议标配?

关键词:# DeepSeek ;# SSE ;# WebSocketSSE 和 WebSocket 是什么? 大模型应用出现前的主流网络通信协议是什么? 为什么大模型应用没有沿用 Web 类应用的主流通信协议? 为什么 SSE 和 WebSocket 更适合支持大模型应用? 实时通信协议的技术挑战和应对方案 Whats Next?Dee…

webSocket在.net中的使用案例

前言前面asp.net实现长连接 - chenxizhaolu - 博客园学习了如何在asp.net中实现http长连接,这里继续学习websocket。WebSockets 是一种协议,它能让客户端和服务器之间通过单个长期连接进行无缝通信。与 HTTP 等遵循请求-响应模式的传统网络通信方法不同,WebSockets 引入了全…

SQL SERVER日常运维巡检系列之-性能

前言做好日常巡检是数据库管理和维护的重要步骤,而且需要对每次巡检日期、结果进行登记,同时可能需要出一份巡检报告。本系列旨在解决一些常见的困扰:不知道巡检哪些东西 不知道怎么样便捷体检 机器太多体检麻烦 生成报告困难,无法直观呈现结果 性能是系统好坏的重要指标之…

burpsuite激活

激活burpsuite——教程点击Start 文件,把三个框都选上点击RUN,会自动启动,复制一下那个证书粘贴刚刚复制的密钥,点击下一个即可这里点击手动激活,复制请求,粘贴到刚刚那个激活程序的:Activation Request 它会自动生成Response,Copy就行到Burpsutie 里面复制一下,然后点…

KBP310-ASEMI整流桥稳定电力的核心担当

KBP310-ASEMI整流桥稳定电力的核心担当编辑:ll 在当今电子科技飞速发展的时代,各类电子设备充斥着我们的生活,从日常使用的手机、电脑,到工业生产中的大型机械,稳定的电力供应都是它们正常运转的基石。而在这背后,有一个常常被忽视却又至关重要的元件 ——KBP310 整流桥。…