File: sshfs.def

package info (click to toggle)
singularity-container 4.1.5%2Bds4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 43,876 kB
  • sloc: asm: 14,840; sh: 3,190; ansic: 1,751; awk: 414; makefile: 413; python: 99
file content (43 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download
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
bootstrap: library
from: alpine:3.15

%post
    apk update
    apk add sshfs dropbear openssh-sftp-server
    loader=`strings /bin/sh | head -n1`

    mkdir /etc/dropbear
    ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa-sha2-512
    mkdir /root/.ssh
    chmod 0600 /root/.ssh
    cp /etc/ssh/ssh_host_rsa_key.pub /root/.ssh/authorized_keys

    mkdir /wrapped

    cat > /sshfs-wrapper <<EOF
#!/bin/sh
# get mount point directory
dir="\${0%/*}"

# export it for other command wrapper
export ROOTDIR_WRAPPER="\$dir"

export LD_LIBRARY_PATH="\$dir/usr/lib:\$dir/lib"
export PATH="\$ROOTDIR_WRAPPER/wrapped:\$PATH"

exec \$dir$loader \$dir/usr/bin/sshfs "\$@"
EOF

    # all commands required by FUSE server must be wrapped
    # to start them with the loader of this image
    cat > /wrapped/ssh <<EOF
#!/bin/sh
exec \$ROOTDIR_WRAPPER$loader \$ROOTDIR_WRAPPER/usr/bin/ssh "\$@"
EOF

    chmod +x /sshfs-wrapper /wrapped/*

%runscript
    dropbear -R -E -s -p 127.0.0.1:2022
    # wait until we receive something on stdin
    cat > /dev/null