Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ssh into "Web App On Linux" docker container on Azure?

How can I ssh into the container with the new "Web App On Linux" service?

It is currently in preview mode, I'm not sure that it is not possible yet or I have overseen the settings.

like image 215
user1497277 Avatar asked Sep 13 '25 00:09

user1497277


2 Answers

Here is an example that I got working with ssh together with a asp.net core app in linux container:

Dockerfile

#base image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base

#ssh
ENV SSH_PASSWD "root:Docker!"
RUN apt-get update \
        && apt-get install -y --no-install-recommends dialog \
        && apt-get update \
  && apt-get install -y --no-install-recommends openssh-server \
  && echo "$SSH_PASSWD" | chpasswd 

COPY MyApp/sshd_config /etc/ssh/
COPY MyApp/init.sh /usr/local/bin/

WORKDIR /app
EXPOSE 80 443 2222

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["MyApp/MyApp.csproj", "MyApp/"]
RUN dotnet restore "MyApp/MyApp.csproj"
COPY . .
WORKDIR "/src/MyApp"
RUN dotnet build "MyApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
    
ENTRYPOINT ["bash","init.sh"]

init.sh in root folder of .net core project

service ssh start
dotnet MyApp.dll

sshd_config in root folder of .net core project

#
# /etc/ssh/sshd_config
#

Port            2222
ListenAddress       0.0.0.0
LoginGraceTime      180
X11Forwarding       yes
Ciphers                 aes128-cbc,3des-cbc,aes256-cbc
MACs                    hmac-sha1,hmac-sha1-96
StrictModes         yes
SyslogFacility      DAEMON
PrintMotd       no
IgnoreRhosts        no
#deprecated option 
#RhostsAuthentication   no
RhostsRSAAuthentication yes
RSAAuthentication   no 
PasswordAuthentication  yes
PermitEmptyPasswords    no
PermitRootLogin     yes

enter image description here

like image 58
Sgedda Avatar answered Sep 15 '25 15:09

Sgedda


For now, It is not possible. Please refer to this feedback.

Update on 2017-6-8

Now, it is possible, please refer to SSH support for Azure Web App on Linux.

like image 25
Shui shengbao Avatar answered Sep 15 '25 14:09

Shui shengbao