-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-docker-openssh.sh
executable file
·69 lines (54 loc) · 1.56 KB
/
start-docker-openssh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
echo "#########################################"
echo "## Mount a Docker volume"
echo "#########################################"
docker volume ls
echo -n "Please type in the volume name you want to edit: "
read sourceDockerVolume
if [ -z "$sourceDockerVolume" ]
then
echo "You did not type in a docker volume name....Exiting."
return
fi
echo "Please type in a mount target folder on the host to mount the Docker volume to:"
echo -n "Mount point: "
read targetMnt
if [ -z "$targetMnt" ]
then
echo "You did not type in mount target....Exiting."
return
fi
echo "Starting Docker container..."
echo "This may take a while, please wait!"
containerId=$(docker run \
-d --rm \
--name=openssh-server \
--hostname=openssh-server \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Europe/Berlin \
-e SUDO_ACCESS=false \
-e PASSWORD_ACCESS=true \
-e USER_NAME=myuser \
-e USER_PASSWORD=changeme \
-p 127.0.0.1:2222:2222 \
-v ${sourceDockerVolume}:/mnt \
linuxserver/openssh-server
)
sleep 15s
echo "Now login with password 'changeme'!"
#ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" myuser@127.0.0.1 -p2222
sshfs -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" myuser@127.0.0.1:/mnt ${targetMnt} -p2222
echo "Successfully mounted Docker volume!"
echo
echo "Goto"
echo " ${targetMnt}"
echo "mount target to see the volume contents."
echo
echo "Use"
echo " umount ${targetMnt}"
echo "to unmount volume."
echo
echo "Use"
echo " docker stop ${containerId}"
echo "to stop the Docker container."