Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
HiveSsh simplifies SSH2 connections via promise-based task execution on Linux servers with built-in server utilities and powerful command execution functions
HiveSsh simplifies SSH2 connections via promise-based task execution on Linux servers with built-in server utilities and powerful command execution functions.
HiveSsh is a library designed to streamline SSH2 connections and task execution on Linux servers. It provides user-friendly promise-based functions for efficient server operations without the need for a client application.
HiveSsh offers the following key features:
All-Distributions: SSH2 and SFTP operations for all Linux servers
Promisified: Promise-based functions for ease of use
AbstractPackageManager: Built-in abstract package manager with support for apt, dnf, and yum, with additional configurability
Exec: Command execution utilities for event or promise-based error handling and output parsing, filtering, and mapping
HiveSsh requires the following server environments:
npm i hivessh
import { SshHost } from "hivelib"
// connect
const myHost = await SshHost.connect({
host: "127.0.0.1",
//port: 22, (default 22)
//user: "root", (default root)
password: "123456789",
})
// or
const myHost = await SshHost.connect({
host: "127.0.0.1",
//port: 22, (default 22)
//user: "root", (default root)
privateKey: "..."
//passphrase: "123456789"
})
// or
const myHost = await SshHost.connect({
host: "127.0.0.1",
//port: 22, (default 22)
//user: "root", (default root)
privateKeyPath:"/home/user/.ssh/id_rsa",
//passphrase: "123456789"
})
Here are some using examples:
After connecting an SshHost
, you can use the promisified execution (and other asset features) directly on the SshHost
instance.
// check files in user home dir
const homeDirFiles = await myHost.exec("ls -al")
console.log("Home dir files:\n", homeDirFiles.out)
Get the hosts public ip address:
// check if curl command exists
const curlExists = await myHost.cmdExists("curl")
if(!curlExists){
myHost.close()
throw new Error("Curl is not installed on: " + myHost.settings.id)
}
const myIp = await myHost.exec("curl ifconfig.me")
console.log("Host public ip: " + myIp.out)
//other sources: `api.ipify.org`, `ipinfo.io/ip` or `ipecho.net/plain`
You can also execute commands on absolut path:
const etcDirFiles = await myHost.exec(
"ls -al",
{ pwd: "/etc" }
)
console.log("Etc files: ", etcDirFiles.out)
Also a git example:
// check if git command exists
const gitExists = await myHost.cmdExists("git")
if(!gitExists){
myHost.close()
throw new Error("Git is not installed on: " + myHost.settings.id)
}
// get git status
const gitStatus = await myHost.exec(
"git status",
{
pwd: "/home/tester/myrepo"
}
)
console.log("Git status:\n", gitStatus.out)
You can also use the promisified SFTP features via SshHost.sftp
.
const myBinary: Buffer = await myHost.sftp.readFile("/home/tester/my-binary")
const exampleConfig: string = await myHost.sftp.readFile("/etc/example/config.yml", "utf8")
With the abstract package manager (apm
) you can use apt
, dnf
, yum
or a custom implemented package manager
via one interface.
The apm features are limited and general, but you can update your system and install, delete and list your packages.
// upgrade all packages using the abstract package manager
const apm = await myHost.getApm()
await apm.updateCache()
await apm.upgradeAll()
// install a package using the abstract package manager
await apm.install("git")
For creating a custon apm you need to implement the following typescript interface: https://github.com/NobleMajo/hivessh/blob/main/src/apm/ApmInterface.ts
After implementing the custom package manager you need to register it global via a checker function:
import { apmChecker, AbstractPackageManager } from "./apm/apm.js"
apmChecker.push(async (host) => {
if (await host.cmdExists("myapm")) {
const myApm: AbstractPackageManager = { ... }
return myApm
}
})
This function is called when the getApm()
is called and can return a package manager depending on the host.
Sessions are available so that the PWD (process working directory) and environment do not have to be specified for every single command. These sessions store that persistent settings across multiple executions and can even resolve relative paths.
const session = host.session("/etc/example")
session.exec("ls -al") // is executed at /etc/example
session.exec("./myApp") // is using MY_APP_ENV_VAR
Example with more options:
const session = host.session("/etc/someapp")
//if sudo is needed enable it for following processes
session.sudo = true
// set process environment variables for following processes
session.env.TZ = "Europe/Berlin"
session.env.NODE_ENV = "production"
// change directory (without checking if exists) for following processes
// shortcut for session.env.PWD = "/etc/someapp/dist"
session.cd("/etc/someapp/dist")
// execute my app with earlier defined environment
session.exec("node myApp.js")
HiveSsh is built using the following technologies:
Contributions to HiveSsh are welcome!
Interested users can refer to the guidelines provided in the CONTRIBUTING.md file to contribute to the project and help improve its functionality and features.
HiveSsh is licensed under the MIT license, providing users with flexibility and freedom to use and modify the software according to their needs.
HiveSsh is provided without warranties.
Users are advised to review the accompanying license for more information on the terms of use and limitations of liability.
FAQs
HiveSsh simplifies SSH2 connections via promise-based task execution on Linux servers with built-in server utilities and powerful command execution functions
We found that hivessh demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.