From b605aad54234af799fb7373045d43efbda09acb9 Mon Sep 17 00:00:00 2001 From: Mark O'Brien Date: Wed, 29 Jul 2020 15:50:16 +0100 Subject: [PATCH] AWS add ssh key to root user and remove fedora user --- remove_fedora_user_at_launch_aws.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 remove_fedora_user_at_launch_aws.md diff --git a/remove_fedora_user_at_launch_aws.md b/remove_fedora_user_at_launch_aws.md new file mode 100644 index 0000000..568bea7 --- /dev/null +++ b/remove_fedora_user_at_launch_aws.md @@ -0,0 +1,18 @@ +# How to add allow root ssh login and remove fedora user + +This will allow you to run ansible playbooks as the root user. +It also removes the fedora user so that fas_client can install sucessfully in `/home/fedora` + +Simply add the below text in to the `User Data` field when launching an EC2 instance. +This appears as a text box at the bottom of the `Configure Instance` step when launching an instance.(Step 3) + + +``` +#!/bin/bash +cat home/fedora/.ssh/authorized_keys > /root/.ssh/authorized_keys +userdel -r fedora +``` + +The script copies the public key from the fedora user and replaces the root users key with it. +This is the public key which is associated with the keypair selected when launching the instance. +It then deletes the Fedora user leaving root as the only ssh user on the instance.