Skip to content

Commit fbf7719

Browse files
committed
initial commit
0 parents  commit fbf7719

File tree

11 files changed

+416
-0
lines changed

11 files changed

+416
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
execd

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (C) 2014 Jeff Lindsay
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
build:
3+
go build .

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# execd
2+
3+
A very lightweight SSH server frontend written in Go. The backend auth and execution logic is handled by commands you specify, letting you customize its behavior via your own scripts/executables.
4+
5+
## Using execd
6+
```
7+
Usage: ./execd [options] <auth-handler> <exec-handler>
8+
9+
-d=false: debug mode displays handler output
10+
-e=false: pass environment to handlers
11+
-k="": pem file of private keys (read from SSH_PRIVATE_KEYS by default)
12+
-p="22": port to listen on
13+
-s=false: run exec handler via SHELL
14+
```
15+
#### auth-handler $user $key
16+
17+
* `$user` argument is the name of the user being used to attempt the connection
18+
* `$key` argument is the public key data being provided for authentication
19+
20+
auth-handler is the path to an executable that's used for authenticating incoming SSH connections. If it returns with exit status 0, the connection will be allowed, otherwise it will be denied. The output of auth-handler must be empty, or key-value pairs in the form `KEY=value` separated by newlines, which will be added to the environment of exec-handler.
21+
22+
Although auth-handler is required, you can still achieve no-auth open access by providing `/usr/bin/true` as auth-handler.
23+
24+
#### exec-handler $command...
25+
26+
* `$command...` arguments is the command line that was specified to run by the SSH client
27+
28+
exec-handler is the path to an executable that's used to execute the command provided by the client. The meaning of that is quite flexible. All of the stdout and stderr is returned to the client, including the exit status. If the client provides stdin, that's passed to the exec-handler. Any environment variables provided by the auth-handler output will be available to exec-handler, as well as `$USER` and `$SSH_ORIGINAL_COMMAND` environment variables.
29+
30+
## Credit / History
31+
32+
It started with [gitreceive](https://github.com/progrium/gitreceive), which was then used in [Dokku](https://github.com/progrium/dokku). Then I made a more generalized version of gitreceive, more similar to execd, called [sshcommand](https://github.com/progrium/sshcommand), which eventually replaced gitreceive in Dokku. When I started work on Flynn, the first projects included [gitreceived](https://github.com/flynn/gitreceived) (a standalone daemon version of gitreceive). This was refined by the Flynn community, namely Jonathan Rudenberg.
33+
34+
Eventually I came to realize gitreceived could be generalized / simplified further in a way that could be used *with* the original gitreceive, *and* replace sshcommand, *and* be used in Dokku, *and* potentially replace gitreceived in Flynn. This project takes learnings from all those projects, though mostly gitreceived.
35+
36+
## Sponsors
37+
38+
This project was made possible thanks to [DigitalOcean](http://digitalocean.com).
39+
40+
## License
41+
42+
BSD

SPONSORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DigitalOcean http://digitalocean.com

example/authcheck

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
USER="$1"
4+
KEY="$2"
5+
6+
generate_fingerprint() {
7+
awk '{print $2}' | base64 -d | md5sum | awk '{print $1}' | sed -e 's/../:&/2g'
8+
}
9+
10+
echo "USER=$USER"
11+
echo "FINGERPRINT=$(echo "$KEY" | generate_fingerprint)"
12+
13+
grep "$KEY" "/home/$USER/.ssh/authorized_keys" > /dev/null 2>&1

example/helloworld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
echo "Hello world"
3+
read hello
4+
echo "OK: $hello"

example/host_pk.pem

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-----BEGIN DSA PRIVATE KEY-----
2+
MIIBuwIBAAKBgQDDDciNHhkVRk5/moDDollqT/wfeXSbyHi78+DhrTkJsngtMHnt
3+
kvKtyd5MZl/FhZRPSWEnQGyYVAzOgeassZFdmoaB1KyqZl0n1ZX1r5uYUV7x/eug
4+
9bWZE2SvsIXkjwJ7Dl7PQh7VfJ0bqGV5G2/py3MaQ3GYOzdN82GoqVDc8wIVAKKN
5+
qd4BpQkfbV4c+orjDv9F55OhAoGBAJdqfCRK065oIWpIar/HVjI4CQpNSLV6sHNz
6+
HzuwGKdxmCFaspakS5qm03ZJH7uosCmVDbkKtF3BfuWbHgGKDDts6Kl8UVtlzdD0
7+
2n1vvOrI7QYDV6G3m2Q3pMsanT58XrfBMr2yL52sS9OCDyhtslzKTqyXhiA48EyM
8+
DKEILuk7AoGASNvt69ON0SwYp1d10D1Y72CO1poBV5DgFtUtumZBgCE9Vz5r81+h
9+
3+PS+33gVgYXCQIpXzcfKN6S3y7oHO8Cf7Mm0Qhd+uO2kihXk7CUVEJj6H1Pl8vE
10+
JgUHtk59G2wvFCXBRC3EMbPXHROPwHbp7XUCz0CEcP954lT7/yTcTf0CFFctTdhZ
11+
qK1yvPS2sOcocADH0pOc
12+
-----END DSA PRIVATE KEY-----

example/id_dsa

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-----BEGIN DSA PRIVATE KEY-----
2+
MIIBuwIBAAKBgQCYyqBjaRkQTCpJnUNKietP/ZyR9/1N3NfjAIX80dEJ5l12ZfvP
3+
a4+fk96Q35bOOXQwvvbG8003Fq+OjNK/PeU1zwvVUrh3jC3qyr+fGkp43ONX82j/
4+
ml8DCxkjQ41iDbW90WQ0qPtjA/78M0hIUp/OELdYwPhebqaSpM+wBVIgQQIVANU2
5+
kCk7ort/1hr0sYOJuDs8nKcfAoGBAIq8I0vSwuqAe/YfamUYn1dhO44mE+UsXFhk
6+
eliHesLPEPWzm7+XRKgUVTNTnoyUsy08FbYwAmAR5zkI62pd0p8iV7hfKfD5Pf9+
7+
CdCt2hbP6r6VXzAuH348pWcgLsxbAzvOEA7r4L4b21VkNquwjuwIe7XbvBeKUj5l
8+
F0i7+WXdAoGAPsUpTU5VoOOvACh/XKlgo7v2mv/DPQLM8pUZaT7N1irKArMV31Kd
9+
sd6iusbIvEk2CLk7AgXBNDrYCSV/c/iXHg3hoPyzDVEI9dV9OILG0hjCqTFnViu5
10+
lXfexYN/+s4NZ1IahyhLSyEUEZA7wx4E7UZKZ5EXWgw4ZGwd5+4yE/0CFHGsZ18k
11+
6ZnyUjegGl6Ze3of6giy
12+
-----END DSA PRIVATE KEY-----

example/id_dsa.pub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-dss AAAAB3NzaC1kc3MAAACBAJjKoGNpGRBMKkmdQ0qJ60/9nJH3/U3c1+MAhfzR0QnmXXZl+89rj5+T3pDfls45dDC+9sbzTTcWr46M0r895TXPC9VSuHeMLerKv58aSnjc41fzaP+aXwMLGSNDjWINtb3RZDSo+2MD/vwzSEhSn84Qt1jA+F5uppKkz7AFUiBBAAAAFQDVNpApO6K7f9Ya9LGDibg7PJynHwAAAIEAirwjS9LC6oB79h9qZRifV2E7jiYT5SxcWGR6WId6ws8Q9bObv5dEqBRVM1OejJSzLTwVtjACYBHnOQjral3SnyJXuF8p8Pk9/34J0K3aFs/qvpVfMC4ffjylZyAuzFsDO84QDuvgvhvbVWQ2q7CO7Ah7tdu8F4pSPmUXSLv5Zd0AAACAPsUpTU5VoOOvACh/XKlgo7v2mv/DPQLM8pUZaT7N1irKArMV31Kdsd6iusbIvEk2CLk7AgXBNDrYCSV/c/iXHg3hoPyzDVEI9dV9OILG0hjCqTFnViu5lXfexYN/+s4NZ1IahyhLSyEUEZA7wx4E7UZKZ5EXWgw4ZGwd5+4yE/0= [email protected]

0 commit comments

Comments
 (0)