Skip to content

Commit

Permalink
use winSCP.com utility to convert private key to ppk to launch winSCP
Browse files Browse the repository at this point in the history
drop node-forge dependency
  • Loading branch information
artu-ole authored and Eugeny committed Nov 1, 2022
1 parent 8b408bd commit 688b9de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
1 change: 0 additions & 1 deletion tabby-ssh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"dependencies": {
"@luminati-io/socksv5": "^0.0.7",
"node-forge": "^1.3.1",
"run-script-os": "^1.1.3",
"tmp-promise": "^3.0.3"
},
Expand Down
9 changes: 3 additions & 6 deletions tabby-ssh/src/services/ssh.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as shellQuote from 'shell-quote'
import * as net from 'net'
import * as fs from 'fs/promises'
import * as tmp from 'tmp-promise'
import * as sshpk from 'sshpk'
import * as forge from 'node-forge'
import socksv5 from '@luminati-io/socksv5'
import { Duplex } from 'stream'
import { Injectable } from '@angular/core'
Expand Down Expand Up @@ -53,10 +51,9 @@ export class SSHService {
let tmpFile: tmp.FileResult|null = null
if (session.activePrivateKey) {
tmpFile = await tmp.file()
const privateKey = await sshpk.parsePrivateKey(session.activePrivateKey, 'auto')/* .toString('putty') */
const forgePrivateKey = forge.pki.decryptRsaPrivateKey(privateKey.toString('pem'))
const ppk = forge.ssh.privateKeyToPutty(forgePrivateKey)
await fs.writeFile(tmpFile.path, ppk)
await fs.writeFile(tmpFile.path, session.activePrivateKey)
const winSCPcom = path.slice(0, -3) + 'com'
await this.platform.exec(winSCPcom, ['/keygen', tmpFile.path, `/output=${tmpFile.path}`])
args.push(`/privatekey=${tmpFile.path}`)
}
await this.platform.exec(path, args)
Expand Down
5 changes: 0 additions & 5 deletions tabby-ssh/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ minimatch@^3.1.1:
dependencies:
brace-expansion "^1.1.7"

node-forge@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3"
integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
Expand Down

0 comments on commit 688b9de

Please sign in to comment.