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

我的梦境 提交于 2020-03-27 19:18:12

问题


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.


回答1:


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.




回答2:


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!




回答3:


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.




回答4:


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 ["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



来源:https://stackoverflow.com/questions/42704656/how-can-i-ssh-into-web-app-on-linux-docker-container-on-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!