Skip to content

Commit e35bd24

Browse files
committed
Merge commit 'f952b0df07859161b644008778d001eabef56315'
2 parents c555ac8 + f952b0d commit e35bd24

File tree

2 files changed

+208
-83
lines changed

2 files changed

+208
-83
lines changed

src/github.com/YuriyNasretdinov/GoSSHa/README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ You send commands and receive response by writing and reading JSON lines, for ex
2020

2121
```
2222
$ GoSSHa
23-
{"InitializeComplete":true}
23+
{"Type":"InitializeComplete","InitializeComplete":true}
2424
{"Action":"ssh","Cmd":"uptime","Hosts":["localhost"]} # your input
25-
{"ConnectedHost":"localhost"}
26-
{"Hostname":"localhost","Stdout":" 1:07 up 1 day, 1:32, 2 users, load averages: 0.90 0.99 1.08\n","Stderr":"","Success":true,"ErrMsg":""}
27-
{"TotalTime":0.082024023,"TimedOutHosts":{}}
25+
{"Type":"ConnectionProgress","ConnectedHost":"localhost"}
26+
{"Type":"Reply","Hostname":"localhost","Stdout":" 1:07 up 1 day, 1:32, 2 users, load averages: 0.90 0.99 1.08\n","Stderr":"","Success":true,"ErrMsg":""}
27+
{"Type":"FinalReply","TotalTime":0.082024023,"TimedOutHosts":{}}
2828
```
2929

3030
GoSSHa continiously reads stdin and writes response to stdout. The protocol can be split into 2 major phases: initialization and execute loop.
@@ -33,12 +33,12 @@ GoSSHa continiously reads stdin and writes response to stdout. The protocol can
3333

3434
## Initialization
3535

36-
To be able to run commands GoSSHa examines `~/.ssh/id_rsa` and `~/.ssh/id_dsa` if present and asks for their passwords if they are encrypted. If ssh-agent auth socket is present (identified by presence of `SSH_AUTH_SOCK` environment variable) then it is used as a primary authentication method with fallback to private keys. Password or keyboard-interactive authentication methods are not currently supported, but there are no technical difficulties for adding them.
36+
To be able to run commands GoSSHa examines `~/.ssh/id_rsa`, `~/.ssh/id_dsa` and `~/.ssh/id_ecdsa` if present and asks for their passwords if they are encrypted. If ssh-agent auth socket is present (identified by presence of `SSH_AUTH_SOCK` environment variable) then it is used as a primary authentication method with fallback to private keys. Password or keyboard-interactive authentication methods are not currently supported, but there are no technical difficulties for adding them.
3737

3838
During initialization, GoSSHa will ask for password for all encrypted private keys it finds, printing message in the following format:
3939

4040
```
41-
{"PasswordFor":"<path-to-private-key>"}
41+
{"Type":"PasswordRequest","PasswordFor":"<path-to-private-key>"}
4242
```
4343

4444
You can respond with empty object (`{}`) or provide the passphrase:
@@ -50,45 +50,45 @@ You can respond with empty object (`{}`) or provide the passphrase:
5050
In case of any non-critical errors (e.g. you did not provide a passphrase or the passphase is invalid) you will receive message in the following format:
5151

5252
```
53-
{"IsCritical":false,"ErrorMsg":"<error-message>"}
53+
{"Type":"UserError","IsCritical":false,"ErrorMsg":"<error-message>"}
5454
```
5555

5656
If critical error occurs then all pending operations will be aborted and you will be presented with the same response but "IsCritical":true, for example:
5757

5858
```
59-
{"IsCritical":true,"ErrorMsg":"Cannot parse JSON: unexpected end of JSON input"}
59+
{"Type":"UserError","IsCritical":true,"ErrorMsg":"Cannot parse JSON: unexpected end of JSON input"}
6060
```
6161

6262
When GoSSHa finishes initialization and is ready to accept commands, the following line will be printed:
6363

6464
```
65-
{"InitializeComplete":true}
65+
{"Type":"InitializeComplete","InitializeComplete":true}
6666
```
6767

6868
## Commands execution
6969

70-
In order to execute a certain `<command>` on remote servers (e.g. `<server1>` and `<server2>`):
70+
In order to execute a certain `<command>` on remote servers (e.g. `<server1>` and `<server2>:<port2>`):
7171

7272
```
73-
{"Action":"ssh","Cmd":"<command>","Hosts":["<server1>","<server2>"]}
73+
{"Action":"ssh","Cmd":"<command>","Hosts":["<server1>","<server2>:<port2>"]}
7474
```
7575

7676
You can also set `"Timeout": <timeout>` in milliseconds (default is 30000 ms)
7777

7878
While connections to hosts are estabilished and command results are ready you will receive one of the following messages:
7979

80-
1. Error messages: `{"IsCritical":false,"ErrorMsg":"<error-message>"}`
81-
2. Connection progress: `{"ConnectedHost":"<hostname>"}`
80+
1. Error messages: `{"Type":"UserError","IsCritical":false,"ErrorMsg":"<error-message>"}`
81+
2. Connection progress: `{"Type":"ConnectionProgress","ConnectedHost":"<hostname>"}`
8282
3. Command result:
8383

8484
```
85-
{"Hostname":"<hostname>","Stdout":"<command-stdout>","Stderr":"<command-stderr>","Success":true|false,"ErrMsg":"<error message>"}
85+
{"Type":"Reply","Hostname":"<hostname>","Stdout":"<command-stdout>","Stderr":"<command-stderr>","Success":true|false,"ErrMsg":"<error message>"}
8686
```
8787

8888
After all commands have done executing or when timeout comes you will receive the following response:
8989

9090
```
91-
{"TotalTime":<total-request-time>,"TimedOutHosts":{"<server1>":true,...,"<serverN>": true}}
91+
{"Type":"FinalReply","TotalTime":<total-request-time>,"TimedOutHosts":{"<server1>":true,...,"<serverN>":true}}
9292
```
9393

9494
For your convenience all hosts that timed out are listed in "TimedOutHosts" property, although you could deduce these hosts by subtracting the sets of hostnames that were present in request and the ones present in response.
@@ -103,11 +103,11 @@ You can also upload file using the following command:
103103
{"Action":"scp","Source":"<source-file-path>","Target":"<target-file-path>","Hosts":[...]}
104104
```
105105

106-
You can also set `"Timeout": <timeout>` in milliseconds (default is 30000 ms)
106+
You can also set `"Timeout": <timeout>` in milliseconds (default is 30000 ms) and `"MaxThroughput": <max-Bps>` in bytes per second to limit maximum bandwidth usage. In default implementation MaxThroughput cannot be less than about 50 Mbit/sec (6553600 bytes per second). If you want to be able to use less bandwidth, try increasing THROUGHPUT_SLEEP_INTERVAL or decreasing MIN_CHUNKS and CHUNK_SIZE constant values in source code.
107107

108108
You will receive progress and results in exactly the same format as for command execution.
109109

110-
**Note:** Source file contents are fully read in memory, so you should not try to upload very large files using this command. If you really need to upload huge file to a lot of hosts, try using bittorrent or UFTP, as they provide much higher network effeciency than SSH.
110+
**Note:** Source file contents are fully read in memory, so you should not upload very large files using this command. If you really need to upload huge file to a lot of hosts, try using bittorrent or UFTP, as they provide much higher network effeciency than SSH.
111111

112112
Source code modification
113113
========================

0 commit comments

Comments
 (0)