File: ssh2.sh

package info (click to toggle)
libssh2 1.2.6-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,512 kB
  • ctags: 1,941
  • sloc: ansic: 19,640; sh: 10,525; makefile: 388; awk: 19
file content (48 lines) | stat: -rwxr-xr-x 911 bytes parent folder | download | duplicates (9)
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
#!/bin/sh

# Written by Simon Josefsson.

# Start sshd, invoke parameters, saving exit code, kill sshd, and
# return exit code.

srcdir=${srcdir:-$PWD}
SSHD=${SSHD:-/usr/sbin/sshd}

cmd="./ssh2${EXEEXT}"
srcdir=`cd "$srcdir"; pwd`

PRIVKEY=$srcdir/etc/user
export PRIVKEY
PUBKEY=$srcdir/etc/user.pub
export PUBKEY

if test -n "$DEBUG"; then
    libssh2_sshd_params="-d -d"
fi

chmod go-rwx "$srcdir"/etc/host*
$SSHD -f /dev/null -h "$srcdir"/etc/host \
    -o 'Port 4711' \
    -o 'Protocol 2' \
    -o "AuthorizedKeysFile $srcdir/etc/user.pub" \
    -o 'UsePrivilegeSeparation no' \
    -o 'StrictModes no' \
    -D \
    $libssh2_sshd_params &
sshdpid=$!

trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT

: "started sshd (${sshdpid})"

sleep 3

: Invoking $cmd...
eval $cmd
ec=$?
: Self-test exit code $ec

: "killing sshd (${sshdpid})"
kill "${sshdpid}" > /dev/null 2>&1
trap "" EXIT
exit $ec