In App Service platform, the WEBSSH feature is backed by openssh-server. For Azure App Service built-in docker images, the platform by default has OpenSSH server configured. But for custom docker image, you will have to setup the OpenSSH server by yourself.
The good news is that RedHat openssh-server package now became available in both authenticated (registry.redhat.io) and unauthenticated (registry.access.redhat.com) registries. That means we can simply now use "yum install" command to install openssh-server in an unregistered docker container.
The following article shows a demonstration of how to enable WebSSH for your customer docker image which is build based on Redhat UBI docker image.
1. Modify your Dockerfile to install OpenSSH server and set root user password.
We can use registry.access.redhat.com/ubi8/ubi or registry.access.redhat.com/ubi7/ubi as the base docker image
Both openssh-server and openssh-clients packages require to be installed
Need to set root user password to "Docker!"
Other than your web application listening port (e.g. 80), we also need to open port 2222 for WEBSSH access
Need to set our customized sshd_config
Create ENTRYPOINT script, since we need to bring up OpenSSH server before booting up your application
2. Create sshd_config file in the same folder as your Dockerfile
# This is ssh server systemwide configuration file.
Subsystem sftp internal-sftp
3. Create init.sh file in the same folder as your Dockerfile
In the following example:
Modify the /etc/profile file to get environment variables to show up in SSH session
Start the /usr/sbin/sshd before booting up my Nginx server.
# Get environment variables to show up in SSH session
eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)
# starting sshd process
# starting Nginx
nginx -g 'daemon off;'