Question: Create a CloudFormation YAML template, named ubuntu-rdp.yaml.In it you will convert the User Data script to be written using the CloudFormation helper scripts, cfn-init (and
Create a CloudFormation YAML template, named ubuntu-rdp.yaml.In it you will convert the User Data script to be written using the CloudFormation helper scripts, cfn-init (and cfn-signal) to setup the Ubuntu 16.04 instance to be accessible via Windows Remote Desktop Protocol (RDP). NOTE: Do NOT setup cfn-hup.
#!bin/bash -xe apt-get update apt-get -y install python-setuptools easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz /usr/local/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} /usr/local/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} Your User Data section may only contain the following code, all the rest of the configurations must happen in the appropriate config sections.
User Data script, the following changes are required. You will have a template parameter for the rdp user and the rdp user's password. Your template will then create that user with the specified password. you need to install xrdp as the last package.
YAML CODE TO USE:
#!/bin/bash # # ubuntu15-rdp # #set this to the username of the rdp user you wish rdpuser="rdpuser" set -e set -x # Skip prompts export DEBIAN_FRONTEND=noninteractive # Set timezone sudo timedatectl set-timezone America/New_York # fix color of directory, which in PuTTy ends up as dark blue on # black background bashrc_append=$(cat <<'EOT' d=.dircolors test -r $d && eval "$(dircolors $d)" EOT ) echo "$bashrc_append" >> /home/ubuntu/.bashrc dircolors -p > /home/ubuntu/.dircolors sed -i -e 's/DIR 01;.*/DIR 01;36 # directory/' /home/ubuntu/.dircolors sudo chown ubuntu:ubuntu /home/ubuntu/.dircolors # Create the remote desktop user sudo adduser $rdpuser --disabled-login --gecos "" sudo usermod -aG sudo $rdpuser motdcontents=$(cat << EOT
| #!/bin/bash | |
| echo "" | |
| echo "Set the password of $rdpuser using sudo passwd $rdpuser" | |
| echo "To fix Tab-completion in XFCE go to Applications->Settings->Window Manager" | |
| echo " Go to Keyboard tab" | |
| echo " Clear option for Switch window for same application" | |
| echo "Delete this reminder using sudo rm /etc/update-motd.d/80-xfce-remind" | |
| EOT | |
| ) | |
| echo "$motdcontents" | sudo tee /etc/update-motd.d/80-xfce-remind | |
| sudo chmod a+x /etc/update-motd.d/80-xfce-remind | |
| # Upgrade | |
| sudo apt-get update | |
| sudo apt-get upgrade -y | |
| # Install packages. | |
| sudo apt-get install -y xrdp xfce4 xfce4-terminal | |
| # set X to use xfce | |
| echo "xfce4-session" | sudo tee /home/$rdpuser/.xsession | |
| sudo chown $rdpuser:$rdpuser /home/$rdpuser/.xsession | |
| sudo service xrdp restart |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
