Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #33 from vieux/private_key
Browse files Browse the repository at this point in the history
ssh config files and/or private keys
  • Loading branch information
vieux authored Sep 5, 2017
2 parents 653cb68 + 69972ed commit d7c3e8e
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
sudo: required
services:
- docker
before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y install docker-ce
env: TESTFILE=integration.sh

script:
Expand Down
74 changes: 42 additions & 32 deletions .travis/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,64 @@ set -x
TAG=test

# before_install
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y install docker-ce
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
#sudo apt-get update
#sudo apt-get -y install docker-ce

# install
docker pull rastasheep/ubuntu-sshd:14.04
docker pull busybox
sudo docker pull rastasheep/ubuntu-sshd
sudo docker pull busybox

docker build -t sshd .travis/ssh
#script

# make the plugin
PLUGIN_TAG=$TAG make
sudo PLUGIN_TAG=$TAG make
# enable the plugin
docker plugin enable vieux/sshfs:$TAG
sudo docker plugin enable vieux/sshfs:$TAG
# list plugins
docker plugin ls
sudo docker plugin ls
# start sshd
docker run -d -p 2222:22 rastasheep/ubuntu-sshd:14.04
sudo docker run -d -p 2222:22 sshd

# test1: simple
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
sudo cat /var/lib/docker/plugins/sshfs-state.json
docker volume rm sshvolume
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume

# test2: allow_other
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write -u nobody busybox sh -c "echo hello > /write/world"
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write -u nobody busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read -u nobody busybox grep -Fxq hello /read/world
sudo cat /var/lib/docker/plugins/sshfs-state.json
docker volume rm sshvolume
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume

# test3: compression
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
sudo cat /var/lib/docker/plugins/sshfs-state.json
docker volume rm sshvolume
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume

# test4: source
docker plugin disable vieux/sshfs:$TAG
docker plugin set vieux/sshfs:$TAG state.source=/tmp
docker plugin enable vieux/sshfs:$TAG
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
sudo cat /tmp/sshfs-state.json
docker volume rm sshvolume
sudo docker plugin disable vieux/sshfs:$TAG
sudo docker plugin set vieux/sshfs:$TAG state.source=/tmp
sudo docker plugin enable vieux/sshfs:$TAG
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /tmp/sshfs-state.json
sudo docker volume rm sshvolume

# test5: ssh key
sudo docker plugin disable vieux/sshfs:$TAG
sudo docker plugin set vieux/sshfs:$TAG sshkey.source=`pwd`/.travis/ssh/
sudo docker plugin enable vieux/sshfs:$TAG
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume
2 changes: 2 additions & 0 deletions .travis/ssh/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM rastasheep/ubuntu-sshd
COPY id_rsa.pub /root/.ssh/authorized_keys
27 changes: 27 additions & 0 deletions .travis/ssh/id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAuwYzjYtn18PcI8GGNUweOZNxj62GhNana2H5ytd4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8eJH89X2PEy/RoLYPUEb1sm4+HJ9p+qDjTu6FF/rXQy
7FFyI0tosklMEggA+mdD+fRHugIjJ3PTN7VekA4L6CO7Inpmkvkm11aUqExR9Hrc
5q4bnVjIGnU3ZHcvrIPQ4QKBgQDExqDql1bi285dRjBa6tLSqjjvj1cU/+XDraCc
iHVYkjaYshtijAhvsGxOKu5KLV4S9Opo1tjLjikxrCVK8R5n1vfuLCdYu0B67zr8
qhLVp3vonlgk0KDBMt2z1sllp/keKY36QmtBKSL2Uh3JVbpl1AnnchM3uJHelJby
RH/dbQKBgCWDV7E2Lo5QDLeuWnfzIcb5bdQRhwLI/9ff59W8msGxxd3ARIt64j3W
FY1/j5hP/K/4ZVjkWebQ7scBdRfxIBj+2/AwTrRSXFAD5qrm8I/1pzyFJ8SJ/cJD
SKCR8dkyJZnqp5XX9RbP/AiY1VN9VHY1RCyV+FKXQD9jpZ0IgxCZ
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions .travis/ssh/id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7BjONi2fXw9wjwYY1TB45k3GPrYaE1qdrYfnK13jNbxKv2n5h9tbkoLcjccS/PUQt/wW0PW6kln9go0fuqWhLkFXTYbqT1IOom4L8wxwq4d9USPFq+9MMHaIKKC6LUJ/evpfFAndPhWIfwith0ylT5+5Wk6W+6cEAMFb7N7TR4g6kjmDjoyjaoF3HKBB86WnZP0PGqUOSvdIroZtwsyFS+eq1z+bfHEa9t1YaXgiM2XlR1LvVESaek3ICSjN+KZH7VcrnJF3+NT/lVeNdfG3EEdbfMaqIeZoiyRGEZwwSHvfaKPck6OOk8eyt9ZFpTTZW5fd0TgAk2J9xp96KsMx/ victorvieux@Victors-MacBook-Pro.local
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This plugin allows you to mount remote folder using sshfs in your container easi

## Usage

### Using a password

1 - Install the plugin

```
Expand Down Expand Up @@ -40,6 +42,41 @@ vieux/sshfs sshvolume
$ docker run -it -v sshvolume:<path> busybox ls <path>
```

### Using an ssh key

1 - Install the plugin

```
$ docker plugin install vieux/sshfs sshkey.source=/home/<user>/.ssh/
# or to enable debug
docker plugin install vieux/sshfs DEBUG=1 sshkey.source=/home/<user>/.ssh/
# or to change where plugin state is stored
docker plugin install vieux/sshfs state.source=<any_folder> sshkey.source=/home/<user>/.ssh/
```

2 - Create a volume

```
$ docker volume create -d vieux/sshfs -o sshcmd=<user@host:path> [-o IdentityFile=/root/.ssh/<key>] [-o port=<port>] [-o <any_sshfs_-o_option> ] sshvolume
sshvolume
$ docker volume ls
DRIVER VOLUME NAME
local 2d75de358a70ba469ac968ee852efd4234b9118b7722ee26a1c5a90dcaea6751
local 842a765a9bb11e234642c933b3dfc702dee32b73e0cf7305239436a145b89017
local 9d72c664cbd20512d4e3d5bb9b39ed11e4a632c386447461d48ed84731e44034
local be9632386a2d396d438c9707e261f86fd9f5e72a7319417901d84041c8f14a4d
local e1496dfe4fa27b39121e4383d1b16a0a7510f0de89f05b336aab3c0deb4dda0e
vieux/sshfs sshvolume
```

3 - Use the volume

```
$ docker run -it -v sshvolume:<path> busybox ls <path>
```

## LICENSE

MIT
12 changes: 12 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
"source"
],
"type": "bind"
},
{
"destination": "/root/.ssh",
"options": [
"rbind"
],
"name": "sshkey",
"source": "",
"settable": [
"source"
],
"type": "bind"
}
],
"network": {
Expand Down

0 comments on commit d7c3e8e

Please sign in to comment.