MCPcopy Index your code
hub / github.com/jetify-com/devbox / setupSSHConfig

Function setupSSHConfig

vscode-extension/src/openinvscode.ts:90–122  ·  view source on GitHub ↗
(vmId: string, prKey: string)

Source from the content-addressed store, hash-verified

88}
89
90async function setupSSHConfig(vmId: string, prKey: string) {
91 const devboxBinary = await which('devbox', { nothrow: true });
92 let devboxPath = 'devbox';
93 if (devboxBinary === null) {
94 devboxPath = await setupDevboxLauncher();
95 }
96 // For testing change devbox to path to a compiled devbox binary or add --config
97 exec(`${devboxPath} generate ssh-config`, (error, stdout, stderr) => {
98 if (error) {
99 window.showErrorMessage('Failed to setup ssh config. Run VSCode in debug mode to see logs.');
100 console.error(`Failed to setup ssh config: ${error}`);
101 return;
102 }
103 console.debug(`stdout: ${stdout}`);
104 console.debug(`stderr: ${stderr}`);
105 });
106
107 // save private key to file
108 const prkeyDir = `${process.env['HOME']}/.config/devbox/ssh/keys`;
109 await ensureDir(prkeyDir);
110 const prkeyPath = `${prkeyDir}/${vmId}.vm.devbox-vms.internal`;
111 try {
112 const prKeydata = new Uint8Array(Buffer.from(prKey));
113 const fileHandler = await open(prkeyPath, 'w');
114 await writeFile(fileHandler, prKeydata, { flag: 'w' });
115 await chmod(prkeyPath, 0o600);
116 await fileHandler.close();
117 } catch (err: any) {
118 // When a request is aborted - err is an AbortError
119 console.error('Failed to setup ssh config: ' + err);
120 throw (err);
121 }
122}
123
124function connectToRemote(username: string, vmId: string, workDir: string) {
125 try {

Callers 1

handleOpenInVSCodeFunction · 0.85

Calls 4

setupDevboxLauncherFunction · 0.85
ensureDirFunction · 0.85
openFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected