银河麒麟配置vscode 远程

序言

使用vscode 远程银河麒麟v10桌面版,怎么都连接不上,所以找了下原因,记录一下。
报错如下
channel 2: open failed: administratively prohibited: open failed
【Vscode Remote】无法连接:Failed to set up socket for dynamic port forward to remote port

安装open-ssh

sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo service ssh status 

配置

首先关闭所有防火墙,或者自行研究开放那个端口
然后
vim /etc/sysctl.conf
####### 修改内容:
net.ipv4.ip_forward = 1
使配置生效:sudo sysctl -p 或者 /sbin/sysctl -e -p /etc/sysctl.conf

然后
vim /etc/ssh/sshd_config

修改一些参数

#	$OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Include /etc/ssh/sshd_config.d/*.conf

Port 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 10

#PubkeyAuthentication 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 yes

AllowAgentForwarding 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 anoncvs
	X11Forwarding yes
	AllowTcpForwarding yes
#	PermitTTY no
#	ForceCommand cvs server
#PermitOpen none


参考上面这些

AllowAgentForwarding yes
AllowTcpForwarding yes   # 允许端口转发
GatewayPorts yes
X11Forwarding yes

# 允许通道打开
PermitTunnel yes

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

这些是需要注意的地方,尤其是#PermitOpen none这个,很多参考资料里面没有写,导致无法成功

最后重启ssh生效

sudo systemctl restart sshd
### 如何在银河麒麟操作系统上安装和配置VSCode #### 安装前准备 为了确保顺利安装 VSCode,在开始之前需确认系统已更新至最新状态并具备必要的依赖库[^1]。 #### 下载与安装 通过官方渠道获取适用于 Linux 的 VSCode 压缩包。对于银河麒麟 V10 版本的操作系统而言,推荐采用 `.deb` 文件格式来简化安装流程[^2]: ```bash wget https://update.code.visualstudio.com/latest/linux-deb-amd64/stable -O vscode.deb sudo dpkg -i vscode.deb ``` 若遇到依赖关系错误提示,则执行以下命令解决依赖问题后再重试安装: ```bash sudo apt-get install -f ``` 完成上述操作后即可启动应用程序进行初步设置。 #### 插件管理注意事项 值得注意的是,在银河麒麟平台上应谨慎处理插件的安装过程。不同于 Windows 平台可以直接在线搜索并添加所需功能模块的方式,在此环境中建议先离线下载所需的扩展文件(.vsix),再利用命令行工具加载这些预下载好的资源以避免潜在兼容性风险[^3]: ```bash code --install-extension path/to/extension.vsix ``` 例如针对 C/C++ 开发场景下的必备组件——CMake Tools 和 C/C++ Extension Pack 可按照如下方法预先准备好对应的 .vsix 文件之后再实施本地化部署: - 访问 [Visual Studio Marketplace](https://marketplace.visualstudio.com/) - 寻找目标插件页面点击 "Download Extension" - 将获得的压缩包上传到服务器相应位置以便后续调用 `code --install-extension` 进行注册激活 #### 后续规划 成功搭建好基础编辑器及其关联工具链之后,可以根据个人需求进一步探索更多高级特性和应用场景,比如构建 Java、Git 或 Maven 支持的综合开发平台等[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

霍志杰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值