Skip to content

Commit cca164e

Browse files
committed
Merge pull request #65 from moul/fix-45
Support of `--host-key=system` to use OpenSSH keys (fix #45)
2 parents 8e921d4 + 7d2f449 commit cca164e

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ COMMANDS:
5050
GLOBAL OPTIONS:
5151
--verbose, -V Enable verbose mode
5252
--bind, -b ":2222" Listen to address
53-
--host-key, -k "built-in" Path or complete SSH host key to use
53+
--host-key, -k "built-in" Path or complete SSH host key to use, use 'system' for keys in /etc/ssh
5454
--allowed-images List of allowed images, i.e: alpine,ubuntu:trusty,1cf3e6c
5555
--shell "/bin/sh" Default shell
5656
--docker-run-args "-it --rm" 'docker run' arguments
@@ -161,6 +161,7 @@ $ docker run --privileged -v /var/lib/docker:/var/lib/docker -it --rm -p 2222:22
161161

162162
### master (unreleased)
163163

164+
* Support of `--host-key=system` to use OpenSSH keys ([#45](https://github.com/moul/ssh2docker/issues/45))
164165
* Support of custom entrypoint ([#63](https://github.com/moul/ssh2docker/issues/63))
165166
* Support of public-key authentication ([#2](https://github.com/moul/ssh2docker/issues/2))
166167
* Handling custom environment variables, user and command in password script ([#57](https://github.com/moul/ssh2docker/issues/57))

cmd/ssh2docker/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func main() {
6767
},
6868
cli.StringFlag{
6969
Name: "host-key, k",
70-
Usage: "Path or complete SSH host key to use",
70+
Usage: "Path or complete SSH host key to use, use 'system' for keys in /etc/ssh",
7171
Value: "built-in",
7272
},
7373
cli.StringFlag{
@@ -151,8 +151,11 @@ func Action(c *cli.Context) {
151151

152152
// Register the SSH host key
153153
hostKey := c.String("host-key")
154-
if hostKey == "built-in" {
154+
switch hostKey {
155+
case "built-in":
155156
hostKey = DefaultHostKey
157+
case "system":
158+
hostKey = "/etc/ssh/ssh_host_rsa_key"
156159
}
157160
err = server.AddHostKey(hostKey)
158161
if err != nil {

0 commit comments

Comments
 (0)