Hello,
I have deployed a simple POC Spring boot application to Azure App Service. The application functions as expected. My Problem is that I cannot connect with SSH. I have followed the steps listed here:
https://learn.microsoft.com/en-us/azure/app-service/configure-linux-open-ssh-session
Here:
https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#enable-ssh
As well as this forum post:
https://learn.microsoft.com/en-us/answers/questions/220501/azure-web-app-with-linux-container-ssh-login-issue.html
I log into the azure portal, find my app service from the Home screen, click on the SSH link to access the SSH blade and get a blank web ssh screen
What am I doing wrong???
Here is my Dockerfile:
FROM openjdk:13-jdk-alpine
USER root
# Add bash
RUN apk update && apk add bash
# add openrc for rc-service command
RUN apk update && apk add openrc
# openssh
RUN apk update && apk add openssh \
&& echo "root:Docker!" | chpasswd
# Copy the sshd_config file to the /etc/ssh/ directory
COPY sshd_config /etc/ssh/
# Copy and configure the ssh_setup file
RUN mkdir -p /tmp
COPY ssh_setup.sh /tmp/
RUN chmod +x /tmp/ssh_setup.sh && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null)
# Create dir where application will run
RUN mkdir -p /opt/web-api-test1
# Create config directory
RUN mkdir -p /opt/web-api-test1/config
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
# Copy over application.properties to config dir
COPY --chown=spring src/main/resources/application.yaml /opt/web-api-test1/config/application.yaml
# Make init.sh executable for spring:spring
COPY --chown=spring init.sh /opt/startup/
RUN chmod 755 /opt/startup/init.sh
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} /opt/web-api-test1/web-api-test1-0.0.1-SNAPSHOT.jar
EXPOSE 8080 2222
ENTRYPOINT ["/opt/startup/init.sh"]
ssh_setup.sh:
#!/bin/sh
echo "running ssh-keygen..."
ssh-keygen -A
echo "ssh-keygen has executed..."
#prepare run dir
if [ ! -d "/var/run/sshd" ]; then
mkdir -p /var/run/sshd
fi
init.sh:
#!/bin/bash
set -e
echo "List contents of /etc/ssh..."
searchDir=/etc/ssh
for entry in "$searchDir"/*
do
FILESIZE=$(stat -c%s "$entry")
echo "FILENAME: $entry FILE SIZE: $FILESIZE"
done
if [ $(ps ax | grep sshd | wc -l) -gt 0 ]; then
echo "sshd is running..."
else
echo "sshd is not running..."
fi
echo "Check if port 8080 is open..."
if [ $(netstat -an |grep 8080 | grep LISTEN | wc -l) -gt 0 ]; then
echo "Port 8080 is open..."
else
echo "Port 8080 is closed..."
fi
echo "Check if port 2222 is open..."
if [ $(netstat -an |grep 2222 | grep LISTEN | wc -l) -gt 0 ]; then
echo "Port 2222 is open..."
else
echo "Port 2222 is closed..."
fi
echo Starting Spring Boot Rest API...
exec java -jar /opt/web-api-test1/web-api-test1-0.0.1-SNAPSHOT.jar