[英]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?如何使用新的“Web App On Linux”服务通过 ssh 进入容器?
It is currently in preview mode, I'm not sure that it is not possible yet or I have overseen the settings.它目前处于预览模式,我不确定这是不可能的,或者我已经监督了设置。
Here is an example that I got working with ssh together with a asp.net core app in linux container:这是我在 linux 容器中将 ssh 与 asp.net 核心应用程序一起使用的示例:
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 .net core 项目根目录下的init.sh
service ssh start
dotnet MyApp.dll
sshd_config in root folder of .net core project .net core 项目根目录下的sshd_config
#
# /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
For now, It is not possible.目前,这是不可能的。 Please refer to this feedback .
请参考此反馈。
Update on 2017-6-8 2017-6-8 更新
Now, it is possible, please refer to SSH support for Azure Web App on Linux .现在,可以了,请参阅Linux 上 Azure Web App 的 SSH 支持。
As of today (4/1/2019) it is possible according to this doc: Connect to Web App for Containers using .截至今天(2019 年 4 月 1 日),根据此文档可以使用: Connect to Web App for Containers using . It's kind of hacking but it does the trick.
这是一种黑客行为,但它确实有效。
Not an April fool's joke.不是愚人节玩笑。
For anyone having issues with @ sgedda 's answer as @ Manish Jain is having, try using:对于@ sgedda的回答有问题的任何人,如@ Manish Jain所拥有的,请尝试使用:
ENTRYPOINT ["bash", "init.sh"]
It worked for me.它对我有用。
I don't believe you can.我不相信你可以。 But depending on what you want to do (eg view log files), you could use bash from Kudu (via Advanced Tools > Debug console > Bash)
但是根据您想要做什么(例如查看日志文件),您可以使用 Kudu 中的 bash(通过高级工具 > 调试控制台 > Bash)
That said, Web App On Linux is in preview - so SSH may be possible in the future!也就是说,Linux 上的 Web 应用程序处于预览阶段 - 所以 SSH 可能在未来成为可能!
I found @Sgedda's reply to be very helpful.我发现@Sgedda 的回复非常有帮助。 I followed his example to the letter, but I kept getting this error
exec user process caused "exec format 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.#!/bin/bash
作为init.sh文件的第一行。 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. service ssh start
是第 2 行。ISO 8859-15
using VS CodeISO 8859-15
LF
using VS CodeLF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.