Skip to content

Commit

Permalink
Add: shellChannel function in SshHost
Browse files Browse the repository at this point in the history
  • Loading branch information
NobleMajo committed May 16, 2024
1 parent 4e7968e commit b7dfec1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hivessh",
"version": "0.3.4",
"version": "0.3.5",
"description": "HiveSsh simplifies SSH2 connections via promise-based task execution on Linux servers with built-in server utilities and powerful command execution functions",
"main": "dist/index.js",
"type": "module",
Expand Down
18 changes: 17 additions & 1 deletion src/SshHost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClientErrorExtensions, SFTPWrapper, Client as SshClient } from "ssh2"
import { ClientChannel, ClientErrorExtensions, SFTPWrapper, Client as SshClient } from "ssh2"
import { ExecSession } from "./ExecSession.js"
import { handleHops } from "./HostHop.js"
import { CmdChannelOptions, CmdExecOptions, SshChannel, SshChannelExit, execSshChannel } from "./SshExec.js"
Expand Down Expand Up @@ -173,6 +173,22 @@ export class SshHost {
}
}

/**
*
* @description Opens a ssh shell channel to handle the shell by yourself
* @returns A promise that resolves when the shell is started and the promise provides you with a session channel
*/
shellChannel(): Promise<ClientChannel> {
return new Promise<ClientChannel>(
(res, rej) => this.ssh.shell(
(err, channel) =>
err ?
rej(err) :
res(channel)
)
)
}

/**
*
* @param pwd Inital path of the session
Expand Down

0 comments on commit b7dfec1

Please sign in to comment.