You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -363,13 +363,10 @@ Group Managed Service Accounts (gMSAs) are currently not supported in Windows co
363
363
364
364
## Enable SSH
365
365
366
-
SSH enables secure communication between a container and a client. In order for a custom container to support SSH, you must add it into your Docker image itself.
367
-
368
-
> [!TIP]
369
-
> All built-in Linux containers in App Service have added the SSH instructions in their image repositories. You can go through the following instructions with the [Node.js 10.14 repository](https://github.com/Azure-App-Service/node/blob/master/10.14) to see how it's enabled there. The configuration in the Node.js built-in image is slightly different, but the same in principle.
370
-
371
-
- Add [an sshd_config file](https://man.openbsd.org/sshd_config) to your repository, like the following example.
366
+
Secure Shell (SSH) is commonly used to execute administrative commands remotely from a command-line terminal. In order to enable the Azure portal SSH console feature with custom containers, the following steps are required:
372
367
368
+
1. Create a standard [sshd_config](https://man.openbsd.org/sshd_config) file with the following example contents and place it on the application project root directory:
369
+
373
370
```
374
371
Port 2222
375
372
ListenAddress 0.0.0.0
@@ -384,54 +381,79 @@ SSH enables secure communication between a container and a client. In order for
384
381
PermitRootLogin yes
385
382
Subsystem sftp internal-sftp
386
383
```
387
-
384
+
388
385
> [!NOTE]
389
-
> This file configures OpenSSH and must include the following items:
386
+
> This file configures OpenSSH and must include the following items in order to comply with the Azure portal SSH feature:
390
387
> - `Port` must be set to 2222.
391
388
> - `Ciphers` must include at least one item in this list: `aes128-cbc,3des-cbc,aes256-cbc`.
392
389
> - `MACs` must include at least one item in this list: `hmac-sha1,hmac-sha1-96`.
393
-
394
-
- Add an ssh_setup script file to create the SSH keys [using ssh-keygen](https://man.openbsd.org/ssh-keygen.1) to your repository.
395
-
390
+
391
+
2. Create an entrypoint script with the name `entrypoint.sh` (or change any existing entrypoint file) and add the command to start the SSH service, along with the application startup command. The following example demonstrates starting a Python application. Please replace the last command according to the project language/stack:
392
+
393
+
### [Debian](#tab/debian)
394
+
395
+
```Bash
396
+
#!/bin/sh
397
+
set -e
398
+
service ssh start
399
+
exec gunicorn -w 4 -b 0.0.0.0:8000 app:app
396
400
```
401
+
402
+
### [Alpine](#tab/alpine)
403
+
404
+
```Bash
397
405
#!/bin/sh
398
-
399
-
ssh-keygen -A
400
-
401
-
#prepare run dir
402
-
if [ ! -d "/var/run/sshd" ]; then
403
-
mkdir -p /var/run/sshd
404
-
fi
406
+
set -e
407
+
/usr/sbin/sshd
408
+
exec gunicorn -w 4 -b 0.0.0.0:8000 app:app
405
409
```
406
-
407
-
- In your Dockerfile, add the following commands:
408
-
410
+
---
411
+
412
+
3. Add to the Dockerfile the following instructions according to the base image distribution. The same will copy the new files, install OpenSSH server, set proper permissions and configure the custom entrypoint, and expose the ports required by the application and SSH server, respectively:
413
+
414
+
### [Debian](#tab/debian)
415
+
409
416
```Dockerfile
410
-
# Install OpenSSH and set the password for root to "Docker!". In this example, "apk add" is the install instruction for an Alpine Linux-based image.
411
-
RUN apk add openssh \
412
-
&& echo "root:Docker!" | chpasswd
413
-
414
-
# Copy the sshd_config file to the /etc/ssh/ directory
> The root password must be exactly `Docker!` as it is used by App Service to let you access the SSH session with the container. This configuration doesn't allow external connections to the container. Port 2222 of the container is accessible only within the bridge network of a private virtual network and is not accessible to an attacker on the internet.
429
453
430
-
- In the start-up script for your container, start the SSH server.
454
+
4. Rebuild and push the Docker image to the registry, and then test the Web App SSH feature on Azure portal.
431
455
432
-
```bash
433
-
/usr/sbin/sshd
434
-
```
456
+
For further troubleshooting additional information is available at the Azure App Service OSS blog: [Enabling SSH on Linux Web App for Containers](https://azureossd.github.io/2022/04/27/2022-Enabling-SSH-on-Linux-Web-App-for-Containers/index.html#troubleshooting)
0 commit comments