Reputation: 469
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.
Upvotes: 3
Views: 9517
Reputation: 1531
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
Upvotes: 8
Reputation: 31
For anyone having issues with @sgedda's answer as @Manish Jain is having, try using:
ENTRYPOINT ["bash", "init.sh"]
It worked for me.
Upvotes: 3
Reputation: 71
I found @Sgedda's reply to be very helpful. I followed his example to the letter, but I kept getting this error exec user process caused "exec format error"
In addition to implementing his example, I also did the following
#!/bin/bash
as the 1st line of the init.sh file. It's important that there is NOTHING in front of it nor at the end of that line AND that it's the 1st line in the file. service ssh start
is line 2.ISO 8859-15
using VS CodeLF
using VS Code
Upvotes: 2
Reputation: 9599
As of today (4/1/2019) it is possible according to this doc: Connect to Web App for Containers using. It's kind of hacking but it does the trick.
Not an April fool's joke.
Upvotes: 2
Reputation: 19195
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.
Upvotes: 3
Reputation: 5690
I don't believe you can. But depending on what you want to do (e.g. view log files), you could use bash from Kudu (via Advanced Tools > Debug console > Bash)
That said, Web App On Linux is in preview - so SSH may be possible in the future!
Upvotes: 1