Skip to content

Commit d9b15a6

Browse files
committed
Installation of Certificates to access Container via SSH-Tunnel
1 parent a4a2a63 commit d9b15a6

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

java_installed.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
dpkg -s openjdk-14-jre | grep -c installed

setup.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
### * A running LXD Server
2222
### * Put the public ssh certificate of the middleman server into the working dir of this script
2323

24-
24+
export DEBIAN_FRONTEND=noninteractive
2525
source config.sh
2626

2727
if [ -f $logfile ] ; then rm $logfile ; fi
@@ -44,9 +44,9 @@ elif test -z "$LOGIN" ; then
4444
read -p "Interactive Brokers Account Login: " LOGIN
4545
fi
4646

47-
if test -n "${3}" ; then
47+
if test -n "${3}"; then
4848
PASS=${3}
49-
elif test -z "$PASS"] ; then
49+
elif test -z "$PASS" ; then
5050
read -p "Interactive Brokers Account Password: " PASS
5151
fi
5252
read -p "Demoaccount? [y|N]:" answer
@@ -219,12 +219,12 @@ init_container(){
219219
sleep $LXD_DELAY
220220

221221
echo "Installiere Java Das dauert einige Minuten ..."
222-
$access_container sudo apt update >> $SILENT
223-
$access_container sudo apt install -y openjdk-14-jre >> $SILENT
222+
$access_container sudo apt-get update >> $SILENT
223+
$access_container sudo apt-get install -y openjdk-14-jre >> $SILENT
224224

225225
# testen, ob java installiert ist:
226226
# $access_container dpkg -s openjdk-14-jre | grep -c installed
227-
echo "Falls java an dieser Stelle nicht installiert wurde ... wir holen dies später noch nach!"
227+
echo "Falls java an dieser Stelle nicht installiert wurde ... wir holen dies später nach!"
228228
lxc file push $IB_PROGRAM $CONTAINER/home/ubuntu/
229229
echo "Installiere ${PRODUCT}. Das dauert einige Minuten ..."
230230
#$access_container DISPLAY= $IB_PROGRAM <<<""$'\n'
@@ -257,9 +257,9 @@ apply_ibc(){
257257
echo "Installation von IBC wird übersprungen."
258258
echo "Es wird keine crontab installiert."
259259
else
260-
$access_container sudo apt install -y openjdk-14-jre >> $SILENT
260+
$access_container sudo apt-get install -y openjdk-14-jre >> $SILENT
261261
$access_container mkdir ibc
262-
$access_container sudo apt install -y unzip cron >> $SILENT
262+
$access_container sudo apt-get install -y unzip cron >> $SILENT
263263
lxc file push $ibc_file $CONTAINER/home/ubuntu/ibc/
264264
$access_container unzip ibc/$ibc_file -d ibc >> $SILENT
265265
$access_container chmod a+x ibc/gatewaystart.sh
@@ -349,7 +349,7 @@ setup_reverse_tunnel(){
349349
check_tunnel
350350
if [ $? -ne 0 ] ; then
351351

352-
$access_container sudo apt install -y openssh-server autossh >> $SILENT # add .ssh dir
352+
$access_container sudo apt-get install -y openssh-server autossh >> $SILENT # add .ssh dir
353353
lxc file push keygen.sh $CONTAINER/home/ubuntu/
354354
$access_container /home/ubuntu/keygen.sh
355355
# download public-key and install it locally
@@ -368,18 +368,20 @@ setup_reverse_tunnel(){
368368

369369
echo " Installiere lokal abgelegte Zertifikate im Container"
370370
# install certificates to access the container via ssh and reverse ssh
371+
touch certificates.sh
371372
for certificate in *.pub
372373
do
373374
[ -f $certificate ] || continue
374375
if [ "$certificate" = dummy.pub ] || [ "$certificate" = $CONTAINER.pub ] ; then
375376
:
376377
else
377378
echo "installiere $certificate "
378-
lxc file push $certificate $CONTAINER/home/ubuntu/
379-
$access_container cat $certificate >> /home/ubuntu/.ssh/authorized_keys
380-
$access_container rm $certificate
379+
cat $certificate >> certificates.sh
381380
fi
382381
done
382+
lxc file push certificates.sh $CONTAINER/home/ubuntu/.ssh/authorized_keys
383+
$access_container chmod 600 /home/ubuntu/.ssh/authorized_keys
384+
rm certificates.sh
383385

384386
echo "#!/bin/sh
385387
@@ -452,6 +454,8 @@ fi
452454

453455
echo "Installiere simple-monitor "
454456
install_simple_monitor
457+
458+
export DEBIAN_FRONTEND=newt
455459
run_ats
456460

457461

0 commit comments

Comments
 (0)