ssh server api
docker pull kainonly/ssh-apiexample
version: '3.7'
services:
ssh:
image: kainonly/ssh-api
restart: always
volumes:
- ./data:/app/data
ports:
- 3000:3000Assume that the underlying request path is http://localhost:3000
- url
/testing - method
POST - body
- host
string - port
number - username
string - password
stringSSH password, default empty - private_key
stringSSH private key (Base64) - passphrase
stringprivate key passphrase
- host
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
numberstatus - msg
stringMessage
- error
{
"error": 0,
"msg": "ok"
}- url
/put - method
POST - body
- identity
stringssh identity code - host
string - port
number - username
string - password
stringSSH password, default empty - private_key
stringSSH private key (Base64) - passphrase
stringprivate key passphrase
- identity
{
"identity":"test",
"host":"imac",
"port":22,
"username":"root",
"private_key":"LS0tL.......tFWS0tLS0tCg=="
}- response
- error
numberstatus - msg
stringMessage
- error
{
"error": 0,
"msg": "ok"
}- url
/exec - method
POST - body
- identity
stringssh identity code - bash
string
- identity
{
"identity":"test",
"bash":"uptime"
}- response
- error
numberstatus - data
stringMessage
- error
{
"error": 0,
"data": " 09:42:22 up 9 days, 23:43, 1 user, load average: 0.26, 0.22, 0.19\n"
}- url
/delete - method
POST - body
- identity
stringssh identity code
- identity
{
"identity":"test"
}- response
- error
numberstatus - msg
stringMessage
- error
{
"error": 0,
"msg": "ok"
}- url
/get - method
POST - body
- identity
stringssh identity code
- identity
{
"identity":"test"
}- response
- error
numberstatus - data
- identity
stringssh identity code - host
string - port
number - username
string - connected
stringssh connected client version - tunnels
arrayssh tunnels set
- identity
- error
{
"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
}
]
}
}- url
/all - method
POST
{
"error": 0,
"data": [
"test"
]
}- url
/lists - method
POST - body
- identity
arrayssh identity code
- identity
{
"identity":["test"]
}- response
- error
numberstatus - data
array- identity
stringssh identity code - host
string - port
number - username
string - connected
stringssh connected client version - tunnels
arrayssh tunnels set
- identity
- error
{
"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
}
]
}
]
}- url
/tunnels - method
POST - body
- identity
stringssh identity code - tunnels
arraytunnels options- src_ip
stringorigin ip - src_port
intorigin port - dst_ip
stringtarget ip - dst_port
inttarget port
- src_ip
- identity
{
"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
numberstatus - msg
stringMessage
- error
{
"error": 0,
"msg": "ok"
}