vscode-1.64之后版本remote-ssh到远端失败

2023-03-06 13:24:42 浏览数 (1)

问题原因

原因是1.64之后vscode加入了“接受条约”的要求,强制要求用户需要去阅读确认后手动修改以表明接受其声明。

解决方案

话不多说直接看问题,我们发现remote-ssh控制台日志上有一个标志性错误信息:

代码语言:javascript复制
server.sh is being replaced by 'bin/code-server'. Please migrate to the new comm
and and adopt the following new default behaviors:

connection token is mandatory unless --without-connection-token is used
host defaults to localhost
Visual Studio Code Server
By using the software, you agree to
the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-lice
nse) and
the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacyst
atement).
To accept the license terms, start the server with --accept-server-license-terms

如上所示,大致意思是,在启动vscode-server服务时需要通过--without-connection-token参数携带token或则携带--accept-server-license-terms参数来表明接受其条约。条约可以查看站点:https://aka.ms/vscode-server-license

看完应该就明白了,这里我采用上述的第二种方案,即在启动vscode-server的时候携带--accept-server-license-terms参数:

1.打开远端服务器的文件(vi ~/.vscode-server/bin/${hash}/server.sh),文件内容如下所示:

代码语言:javascript复制
#!/usr/bin/env sh
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#

case "$1" in
	--inspect*) INSPECT="$1"; shift;;
esac

ROOT="$(dirname "$0")"

"$ROOT/node" ${INSPECT:-} "$ROOT/out/server-main.js" --compatibility=1.63 "$@"

2.追加--accept-server-license-terms参数,修改后的文件如下所示:

代码语言:javascript复制
#!/usr/bin/env sh
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#

case "$1" in
	--inspect*) INSPECT="$1"; shift;;
esac

ROOT="$(dirname "$0")"

"$ROOT/node" ${INSPECT:-} "$ROOT/out/server-main.js" --compatibility=1.63 --accept-server-license-terms "$@"

3.再次用vscode连接远端机器,发现连接成功。

ide

0 人点赞