# 使用 vscode remote-ssh 连接 openEuler
直接连接失败,查看日志发现
vscode-scp-done.flag 0% 0 0.0KB/s --:-- ETA
vscode-scp-done.flag 100% 9 5.0KB/s 00:00
[18:21:35.685] "Copy server to host" terminal command done
[18:21:36.787] > Found flag and server on host
[18:21:36.805] > f85a30ca0d5d%%2%%
> tar --version:
[18:21:36.805] stderr> main:行405: tar:未找到命令
[18:21:36.808] stderr> main:行406: tar:未找到命令
[18:21:36.815] stderr> mv: 无法获取'vscode-server*/*' 的文件状态(stat): 没有那个文件或目录
[18:21:36.816] > ERROR: /root/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/node or /root/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/server.sh don't exist
> Already attempted local download, failing
分析应该是没有 tar 解压工具,使用 ssh 连接到 openEuler
[root@localhost ~]# tar
-bash: tar:未找到命令
[root@localhost ~]#
安装 tar 工具
[root@localhost ~]# dnf install tar
上次元数据过期检查:0:31:57 前,执行于 2021年01月02日 星期六 17时53分08秒。
依赖关系解决。
=============================================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================================
安装:
tar x86_64 2:1.32-1.oe1 OS 772 k
事务概要
=============================================================================================================================================================================
安装 1 软件包
总下载:772 k
安装大小:3.2 M
确定吗?[y/N]: y
下载软件包:
tar-1.32-1.oe1.x86_64.rpm 887 kB/s | 772 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 883 kB/s | 772 kB 00:00
警告:/var/cache/dnf/OS-fcb43ce6e8cef091/packages/tar-1.32-1.oe1.x86_64.rpm: 头V3 RSA/SHA1 Signature, 密钥 ID b25e7f66: NOKEY
OS 18 kB/s | 2.1 kB 00:00
导入 GPG 公钥 0xB25E7F66:
Userid: "private OBS (key without passphrase) <defaultkey@localobs>"
指纹: 12EA 74AC 9DF4 8D46 C69C A0BE D557 065E B25E 7F66
来自: http://repo.openeuler.org/openEuler-20.03-LTS-SP1/OS/x86_64/RPM-GPG-KEY-openEuler
确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
运行脚本: tar-2:1.32-1.oe1.x86_64 1/1
安装 : tar-2:1.32-1.oe1.x86_64 1/1
运行脚本: tar-2:1.32-1.oe1.x86_64 1/1
验证 : tar-2:1.32-1.oe1.x86_64 1/1
已安装:
tar-2:1.32-1.oe1.x86_64
完毕!
[root@localhost ~]#
再次连接,继续报错
[18:26:33.567] Failed to set up socket for dynamic port forward to remote port 45319: Socket closed. Is the remote port correct?
[18:26:33.626] [Forwarding server 51275] Got connection 1
[18:26:33.626] [Forwarding server 51275] Got connection 2
[18:26:33.629] Failed to set up socket for dynamic port forward to remote port 45319: Socket closed. Is the remote port correct?
[18:26:33.631] Failed to set up socket for dynamic port forward to remote port 45319: Socket closed. Is the remote port correct?
分析是端口转发未开启,查看 sshd 服务配置文件
[root@localhost ~]# cat /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/local/bin:/usr/bin:/usr/local/sbin:/usr/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.
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#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
SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#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
PasswordAuthentication yes
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes
# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users 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'.
# WARNING: 'UsePAM no' is not supported in openEuler and may cause several
# problems.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding no
#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 no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server -l INFO -f AUTH
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
#CheckUserSplash yes
# To modify the system-wide ssh configuration, create a *.conf file under
# /etc/ssh/sshd_config.d/ which will be automatically included below
#Include /etc/ssh/sshd_config.d/*.conf
Protocol 2
LogLevel VERBOSE
PubkeyAuthentication yes
RSAAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
PermitUserEnvironment no
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
ClientAliveCountMax 0
Banner /etc/issue.net
MACs hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com
StrictModes yes
AllowTcpForwarding no
AllowAgentForwarding no
GatewayPorts no
PermitTunnel no
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
修改以下配置为yes
,最小安装下有 vi 没有 vim,不过 vi 也够用了。
AllowTcpForwarding yes
AllowAgentForwarding yes
重启 sshd 服务
systemctl restart sshd.service
再次使用remote-ssh连接。。成功了。