-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·37 lines (28 loc) · 831 Bytes
/
start.sh
File metadata and controls
executable file
·37 lines (28 loc) · 831 Bytes
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
#!/bin/bash
stacktrace () {
echo "FAIL: unhandled error. stacktrace:"
i=0
while caller $i; do
i=$((i+1))
done
}
set -Eeuo pipefail
trap "stacktrace" ERR
if [ -z "${1}" ]; then
echo 'Give Authorized key as args.'
echo -e 'Example of command line:
ssh -CD 1080 -o ProxyCommand="docker run --rm -i cell/ssh-over-docker $(cat ~/.ssh/id_rsa.pub)" root@127.0.0.1'
exit 1
fi
#Generating keys...
ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key >/dev/null
ssh-keygen -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key >/dev/null
ssh-keygen -t ecdsa -N '' -f /etc/ssh/ssh_host_ecdsa_key >/dev/null
ssh-keygen -t ed25519 -N '' -f /etc/ssh/ssh_host_ed25519_key >/dev/null
#Add authorized key: ${@}
mkdir /root/.ssh
echo ${@} >/root/.ssh/authorized_keys
#Starting sshd
/usr/sbin/sshd -E /var/log/sshd.log
sleep 1
nc 127.0.0.1 22