Skip to content

Instantly share code, notes, and snippets.

@martinnormark
Last active May 16, 2020 09:55
Show Gist options
  • Save martinnormark/5c0d9d2b33723790b06a60f7b0e9cb6b to your computer and use it in GitHub Desktop.
Save martinnormark/5c0d9d2b33723790b06a60f7b0e9cb6b to your computer and use it in GitHub Desktop.
Create Azure Container Instance with SSH support.

Creating the container

environemnt vars to set:
NAME = Martin
SSHUSER = martin
SSHPWD = pwdnitram

command to run: [ "/bin/bash", "-c", "echo hello $NAME; tail -f /dev/null" ]

Configure SSH

Add a user

useradd -s /bin/bash $SSHUSER

Assign sudo privileges

adduser $SSHUSER sudo
echo $SSHUSER:$SSHPWD | chpasswd

Setup user home folder

cd /home;  
sudo mkdir $SSHUSER  
sudo chown $SSHUSER:$SSHUSER $SSHUSER  
sudo usermod -d /home/$SSHUSER $SSHUSER  

Install openssh server

apt-get update && apt-get install -y openssh-server

Install htop for a better resource monitor

apt-get install htop

Create needed directory for ssh-server

mkdir -p /var/run/sshd

Start ssh server

service ssh restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment