fix: check if private/public ssh key exists before first connect in both local and remote environment
This commit is contained in:
@@ -35,16 +35,23 @@ export default class RemoteContainer {
|
||||
title: vscode.l10n.t("Installing vscode-server and devstar extension in container"),
|
||||
cancellable: false
|
||||
}, async (progress) => {
|
||||
if (vscode.env.remoteName) {
|
||||
// 远程环境
|
||||
// 检查公私钥是否存在,如果不存在,需要创建
|
||||
try {
|
||||
// 无论local/remote,均需检查公私钥是否存在,如果不存在,需要创建(因为有可能在remote上创建了,但是local未创建)
|
||||
if (!this.user.existUserPrivateKey() || !this.user.existUserPublicKey()) {
|
||||
this.user.createUserSSHKey()
|
||||
await this.user.createUserSSHKey()
|
||||
// 上传公钥
|
||||
const devstarAPIHandler = new DevstarAPIHandler()
|
||||
await devstarAPIHandler.uploadUserPublicKey(this.user)
|
||||
const uploadResult = await devstarAPIHandler.uploadUserPublicKey(this.user)
|
||||
if (uploadResult !== "ok") {
|
||||
throw new Error('Upload public key failed.')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to first connect container: ", error)
|
||||
}
|
||||
|
||||
if (vscode.env.remoteName) {
|
||||
// 远程环境
|
||||
try {
|
||||
// 第一次连接
|
||||
await ssh.connect({
|
||||
|
Reference in New Issue
Block a user