Skip to content

Commit

Permalink
Merge pull request #78 from Natizyskunk/fix-ssh-config
Browse files Browse the repository at this point in the history
Fix ssh config
  • Loading branch information
Natizyskunk authored Oct 27, 2021
2 parents 3a4e190 + b8ab0be commit 4ea378a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.15.6 - 2021-10-27
* Fix ssh config resolution (Merged pull request [#69](https://github.com/Natizyskunk/vscode-sftp/pull/69) from clemyan/fix-ssh-config).

## 1.15.5 - 2021-10-27
* Update mtime after file was saved before upload. (Merged pull request [#75](https://github.com/Natizyskunk/vscode-sftp/pull/75) from viperet/save_before_upload_mtime).
* Update mtime after file was saved before upload (Merged pull request [#75](https://github.com/Natizyskunk/vscode-sftp/pull/75) from viperet/save_before_upload_mtime).
* Add pull request issue template.
* Add funding/sponsors page.
* Add code scanning alert.
Expand Down Expand Up @@ -199,7 +202,7 @@
* [Config in User Setting](https://github.com/liximomo/vscode-sftp#config-in-user-setting) config your remote in User Setting

### Fix
* fix sshConfig file not overwriting default config. ([#305](https://github.com/liximomo/vscode-sftp/issues/305))
* fix sshConfig file not overwriting default config ([#305](https://github.com/liximomo/vscode-sftp/issues/305))

## 1.4.0 - 2018-08-27
### Feature
Expand Down Expand Up @@ -247,7 +250,7 @@

## 1.1.8 - 2018-05-15
* Some UX improvements.
* Only show `sftp` menu when extension get activated. (Thanks [@mikolino](https://github.com/mikolino))
* Only show `sftp` menu when extension get activated (Thanks [@mikolino](https://github.com/mikolino))
* Remove some unnecessary warning.
* Improve ftp reliability.
* Upgrade `ssh2` version.
Expand Down Expand Up @@ -336,7 +339,7 @@
## 0.8.9 - 2017-11-17
* Preserve file permissions.
* Better README thanks [kataklys](https://github.com/kataklys).
* Fix Empty (0kb) files when download and uplaod. Thanks for [kataklys](https://github.com/kataklys)'s help. ([#33](https://github.com/liximomo/vscode-sftp/issues/33))
* Fix Empty (0kb) files when download and uplaod. Thanks for [kataklys](https://github.com/kataklys)'s help ([#33](https://github.com/liximomo/vscode-sftp/issues/33))
* Show a waring for existing none-worksapce-root config files. Previously you can create multiple config files anywhere under workspace. So you won't need to open multiple vscode instances to make `sftp` working in different folders. Sincle vscode support [Multi-root Workspaces](https://code.visualstudio.com/docs/editor/multi-root-workspaces). There is no necessary to support multiple config now. This will make `sftp` both simple and a bettern starup performace.

## 0.8.8 - 2017-11-11
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sftp",
"displayName": "SFTP",
"description": "SFTP/FTP sync",
"version": "1.15.5",
"version": "1.15.6",
"publisher": "Natizyskunk",
"author": "Natizyskunk <[email protected]> (https://github.com/Natizyskunk)",
"engines": {
Expand Down
20 changes: 7 additions & 13 deletions src/core/fileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,36 +233,30 @@ function mergeConfigWithExternalRefer(
}

const parsedSSHConfig = sshConfig.parse(sshConfigContent);
const section = parsedSSHConfig.find({
Host: copyed.host,
});

if (section === null) {
return copyed;
}
const computed = parsedSSHConfig.compute(copyed.host);

const mapping = new Map([
['hostname', 'host'],
['port', 'port'],
['user', 'username'],
['identityfile', 'privateKeyPath'],
['serveraliveinterval', 'keepalive'],
['connecttimeout', 'connTimeout'],
]);

section.config.forEach(line => {
if (!line.param) {
Object.entries<any>(computed).forEach(([param, value]) => {
if (param.toLowerCase() === 'identityfile') {
setConfigValue(copyed, 'privateKeyPath', value[0]);
return;
}

const key = mapping.get(line.param.toLowerCase());
const key = mapping.get(param.toLowerCase());

if (key !== undefined) {
// don't need consider config priority, always set to the resolve host.
if (key === 'host') {
copyed[key] = line.value;
copyed[key] = value;
} else {
setConfigValue(copyed, key, line.value);
setConfigValue(copyed, key, value);
}
}
});
Expand Down

0 comments on commit 4ea378a

Please sign in to comment.