You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight SSH server frontend written in Go. Authentication and connections
3
+
A lightweight SSH server frontend where authentication and connections
4
4
are controlled with command handlers / shell scripts.
5
5
6
6
## Using sshfront
7
7
```
8
8
Usage: ./sshfront [options] <handler>
9
9
10
-
-d=false: debug mode displays handler output
11
-
-e=false: pass environment to handlers
12
-
-k="": pem file of private keys (read from SSH_PRIVATE_KEYS by default)
13
-
-h="": host ip to listen on
10
+
-a="": authentication hook. empty=allow all
11
+
-d=false: debug mode
12
+
-e=false: pass environment to handler
13
+
-h="0.0.0.0": ip to listen on
14
+
-k="~/.ssh/id_rsa": private host key path
14
15
-p="22": port to listen on
15
16
```
16
17
17
18
18
-
#### auth-handler $user $key
19
+
#### handler $command...
19
20
20
-
*`$user` argument is the name of the user being used to attempt the connection
21
-
*`$key` argument is the public key data being provided for authentication
22
-
23
-
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
+
*`$command...` command line arguments specified to run by the SSH client
24
22
25
-
Although auth-handler is required, you can still achieve no-auth open access by providing `/usr/bin/true` as auth-handler.
23
+
The handler is a command that's used to handle all SSH connections. Output, stderr, and the exit code is returned to the client. If the client provides stdin, that's passed to the handler.
26
24
25
+
If the authentication hook was specified, any output is parsed as environment variables and added to the handler environment. `$USER` is always the SSH user used to connect and `$SSH_ORIGINAL_COMMAND` is the command specified from the client if not interactive.
27
26
28
-
#### exec-handler $command...
27
+
#### auth-hook $user $key
29
28
30
-
*`$command...` arguments is the command line that was specified to run by the SSH client
29
+
*`$user` argument is the name of the user being used to attempt the connection
30
+
*`$key` argument is the public key data being provided for authentication
31
31
32
-
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.
32
+
The auth hook is a command 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 hook must be empty, or key-value pairs in the form `KEY=value` separated by newlines, which will be added to the environment of connection handler.
33
33
34
+
The auth hook is optional, but if not specified then all connections are allowed.
35
+
It is a good idea to always specify an auth hook.
34
36
35
37
## Examples
36
38
37
-
**These examples bypass all authentication and allow remote execution, *do not* run this in production.**
39
+
**Many of these bypass authentication and may allow remote execution, *do not* run this in production.**
38
40
39
-
Echo server (with accept-all auth):
41
+
Echo server:
40
42
41
43
```
42
-
server$ sshfront $(which true) $(which echo)
44
+
server$ sshfront $(which echo)
43
45
client$ ssh $SERVER "hello world"
44
46
hello world
45
47
```
46
48
47
-
Echo host's environment to clients (with accept-all auth):
49
+
Echo host's environment to clients:
48
50
49
51
```
50
-
server$ sshfront -e $(which true) $(env)
52
+
server$ sshfront -e $(env)
51
53
client$ ssh $SERVER
52
54
USER=root
53
55
HOME=/root
54
56
LANG=en_US.UTF-8
55
57
...
56
58
```
57
59
58
-
Bash server (with accept-all auth):
60
+
Bash server:
59
61
60
62
```
61
-
server$ sshfront $(which true) $(which bash)
63
+
server$ sshfront $(which bash)
62
64
client$ ssh $SERVER
63
65
bash-4.3$ echo "this is a bash instance running on the server"
64
66
this is a bash instance running on the server
@@ -67,8 +69,8 @@ this is a bash instance running on the server
67
69
68
70
## Sponsors
69
71
70
-
This project was made possible thanks to [DigitalOcean](http://digitalocean.com).
72
+
This project was made possible thanks to [Deis](http://deis.io) and [DigitalOcean](http://digitalocean.com).
0 commit comments