Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

kainonly/ssh-api

Repository files navigation

ssh api

ssh server api

GitHub go.mod Go version Travis Docker Pulls GitHub license

docker pull kainonly/ssh-api

Docker Compose

example

version: '3.7'
services:
  ssh:
    image: kainonly/ssh-api
    restart: always
    volumes: 
      - ./data:/app/data
    ports:
      - 3000:3000

Api docs

Assume that the underlying request path is http://localhost:3000

Testing Connect

  • url /testing
  • method POST
  • body
    • host string
    • port number
    • username string
    • password string SSH password, default empty
    • private_key string SSH private key (Base64)
    • passphrase string private key passphrase

Password connect

{
    "host":"imac",
    "port":22,
    "username":"root",
    "password":"123456"
}

Private key connect

{
    "host":"imac",
    "port":22,
    "username":"root",
    "private_key":"LS0tL.......tFWS0tLS0tCg=="
}
  • response
    • error number status
    • msg string Message
{
    "error": 0,
    "msg": "ok"
}

Put SSH

  • url /put
  • method POST
  • body
    • identity string ssh identity code
    • host string
    • port number
    • username string
    • password string SSH password, default empty
    • private_key string SSH private key (Base64)
    • passphrase string private key passphrase
{
    "identity":"test",
    "host":"imac",
    "port":22,
    "username":"root",
    "private_key":"LS0tL.......tFWS0tLS0tCg=="
}
  • response
    • error number status
    • msg string Message
{
    "error": 0,
    "msg": "ok"
}

Exec SSH

  • url /exec
  • method POST
  • body
    • identity string ssh identity code
    • bash string
{
    "identity":"test",
    "bash":"uptime"
}
  • response
    • error number status
    • data string Message
{
    "error": 0,
    "data": " 09:42:22 up 9 days, 23:43,  1 user,  load average: 0.26, 0.22, 0.19\n"
}

Delete SSH

  • url /delete
  • method POST
  • body
    • identity string ssh identity code
{
    "identity":"test"
}
  • response
    • error number status
    • msg string Message
{
    "error": 0,
    "msg": "ok"
}

Get SSH

  • url /get
  • method POST
  • body
    • identity string ssh identity code
{
    "identity":"test"
}
  • response
    • error number status
    • data
      • identity string ssh identity code
      • host string
      • port number
      • username string
      • connected string ssh connected client version
      • tunnels array ssh tunnels set
{
    "error": 0,
    "data": {
        "identity": "test",
        "host": "imac",
        "port": 22,
        "username": "root",
        "connected": "SSH-2.0-Go",
        "tunnels": [
            {
                "src_ip": "127.0.0.1",
                "src_port": 5601,
                "dst_ip": "127.0.0.1",
                "dst_port": 5601
            }
        ]
    }
}

Get All Identity

  • url /all
  • method POST
{
    "error": 0,
    "data": [
        "test"
    ]
}

Lists SSH

  • url /lists
  • method POST
  • body
    • identity array ssh identity code
{
    "identity":["test"]
}
  • response
    • error number status
    • data array
      • identity string ssh identity code
      • host string
      • port number
      • username string
      • connected string ssh connected client version
      • tunnels array ssh tunnels set
{
    "error": 0,
    "data": [
        {
            "identity": "test",
            "host": "imac",
            "port": 22,
            "username": "root",
            "connected": "SSH-2.0-Go",
            "tunnels": [
                {
                "src_ip": "127.0.0.1",
                "src_port": 5601,
                "dst_ip": "127.0.0.1",
                "dst_port": 5601
                }
            ]
        }
    ]
}

Set Tunnel

  • url /tunnels
  • method POST
  • body
    • identity string ssh identity code
    • tunnels array tunnels options
      • src_ip string origin ip
      • src_port int origin port
      • dst_ip string target ip
      • dst_port int target port
{
    "identity":"test",
    "tunnels":[
        {
            "src_ip":"127.0.0.1",
            "src_port":3306,
            "dst_ip":"127.0.0.1",
            "dst_port":3306
        },
        {
            "src_ip":"127.0.0.1",
            "src_port":9200,
            "dst_ip":"127.0.0.1",
            "dst_port":9200
        }
    ]
}
  • response
    • error number status
    • msg string Message
{
    "error": 0,
    "msg": "ok"
}

About

Manage remote SSH clients using HTTP API

Resources

License

Stars

Watchers

Forks

Packages

No packages published