|
1 | 1 | # bashRPC
|
2 | 2 | Simple HTTP server that executes configured commands remotely.
|
3 | 3 |
|
| 4 | +### Why use bashRPC instead of chef/ansible/saltstack/etc? |
| 5 | + |
| 6 | +Use bashRPC when you don't want to give complete super user privileges. That prevents situations like: |
| 7 | + |
| 8 | +``` |
| 9 | +salt "*" cmd.run "rm -rf /" |
| 10 | +# - or - |
| 11 | +ansible -i production all -a "rm -rf /" |
| 12 | +``` |
| 13 | + |
| 14 | +Instead, you can configure an endpoint that does only a select few super user tasks, such as restarting a system service, etc. |
4 | 15 |
|
5 | 16 | ### Installation
|
6 | 17 |
|
@@ -63,7 +74,34 @@ sudo systemctl start bashrpc
|
63 | 74 | 3) ping server
|
64 | 75 |
|
65 | 76 | ```bash
|
66 |
| -curl -k -H "Authorization: supersecret" https://localhost:8675/uptime |
| 77 | +$ curl -k -H "Authorization: supersecret" https://localhost:8675/uptime |
| 78 | +``` |
| 79 | + |
| 80 | +### Security |
| 81 | + |
| 82 | +There are few security measures implemented in bashRPC: |
| 83 | + |
| 84 | +* No HTTP traffic. HTTPS is required. |
| 85 | +* User can specify their own SSL certificate, if desired. |
| 86 | +* Restricted to whitelist of IP addresses. |
| 87 | +* `Authorization` header is required for authentication on every request. |
| 88 | +* No parameterized inputs. Every command must be pre-configured in `bashrpc.yml`. |
| 89 | + |
| 90 | +### Output |
| 91 | + |
| 92 | +bashRPC returns plain text responses, very similar if you were to be executing a command over SSH. This makes it easy to save responses to a variable, check for status code, etc. Both STDOUT and STDERR are combined in the output. |
| 93 | + |
67 | 94 | ```
|
| 95 | +$ curl -k -H "Authorization: supersecret" https://localhost:8675/uptime |
| 96 | +14:31:29 up 1 day, 1:16, 2 users, load average: 1.77, 1.47, 1.43 |
| 97 | +``` |
| 98 | + |
| 99 | +If you care about whether or not your command fails, you can check the response. Using `curl`, for example, you can exit non-zero if a command fails using the `--fail` argument: |
68 | 100 |
|
| 101 | +``` |
| 102 | +$ curl -k -H --fail "Authorization: supersecret" https://localhost:8675/iwillfail |
| 103 | +iwillfail: command not found |
69 | 104 |
|
| 105 | +$ echo "$?" |
| 106 | +1 |
| 107 | +``` |
0 commit comments