Score:0

user data scripts not working for me during starting of the EC2 instance

ru flag

All,

I have user data script like below.

Content-Type: multipart/mixed; boundary="==BOUNDARY=="
MIME-Version: 1.0
--==BOUNDARY==
MIME-Version: 1.0
Content-Type: text/cloud-config; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud_config_data"

#cloud-config
users:
- name: insight
  ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgOhHW7poiNcQmn9P+SfJ7Vt92OI9PrOqaMa3/E2YHhjvPPE4TyFjvCZnjve0CFvwSKXLjIcNJZFY2jNboFsrjlIJgpe6ahGi0kaz8e2zqXyZYOpdKdqpoT47Jzt2L2PSlYow1iBALYXmwzmespWyaUJRzA2wemZu2f9Fxm5YS4D1JOkvl24Ro+uikU/bZk3gFJL4wUjc5g8h7Yavx2ps/mNO88BGutSKiqrlKFjErTAM+bzCFjHr6c7G6H1siHf4CP30i1cE3If+QkbKgdop2kPpd/j3E/4W/PITroHcvtmJ/R25grOS176PvaiPDQmpeHdZJw6RuYbW0Wq84Vq4N [email protected]
- name: oracle
  ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgOhHW7poiNcQmn9P+SfJ7Vt92OI9PrOqaMa3/E2YHhjvPPE4TyFjvCZnjve0CFvwSKXLjIcNJZFY2jNboFsrjlIJgpe6ahGi0kaz8e2zqXyZYOpdKdqpoT47Jzt2L2PSlYow1iBALYXmwzmespWyaUJRzA2wemZu2f9Fxm5YS4D1JOkvl24Ro+uikU/bZk3gFJL4wUjc5g8h7Yavx2ps/mNO88BGutSKiqrlKFjErTAM+bzCFjHr6c7G6H1siHf4CP30i1cE3If+QkbKgdop2kPpd/j3E/4W/PITroHcvtmJ/R25grOS176PvaiPDQmpeHdZJw6RuYbW0Wq84Vq4N [email protected]
- name: admin
  ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgOhHW7poiNcQmn9P+SfJ7Vt92OI9PrOqaMa3/E2YHhjvPPE4TyFjvCZnjve0CFvwSKXLjIcNJZFY2jNboFsrjlIJgpe6ahGi0kaz8e2zqXyZYOpdKdqpoT47Jzt2L2PSlYow1iBALYXmwzmespWyaUJRzA2wemZu2f9Fxm5YS4D1JOkvl24Ro+uikU/bZk3gFJL4wUjc5g8h7Yavx2ps/mNO88BGutSKiqrlKFjErTAM+bzCFjHr6c7G6H1siHf4CP30i1cE3If+QkbKgdop2kPpd/j3E/4W/PITroHcvtmJ/R25grOS176PvaiPDQmpeHdZJw6RuYbW0Wq84Vq4N [email protected]
runcmd:                                                                                                                                                                   - usermod -p '$6$lNYaFbXldWh3c0Rv$qasHT06upnZTbK9dsrhtPmw1fIWgcdda/jX4N2NCTjyU4RRCowcvavoItgFhc5Q7BdtVd1Chv7BoQY7Wo.hDP.' admin
  - pam_tally2 --user=admin --reset
                                                                                                                                                                        --==BOUNDARY==                                                                                                                                                          MIME-Version: 1.0                                                                                                                                                       Content-Type: text/text; charset="us-ascii"                                                                                                                             Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="placeholder.txt"                                                                                                             {                                                                                                                                                                         "InstanceName": "test001-ems",                                                                                                                                          "NtpServer": "10.1.1.6",                                                                                                                                                "DnsServer": "10.2.1.2"                                                                                                                                               }                                                                                                                                                                       --==BOUNDARY==    

can someone tell me what could be wrong in the script? I want to log in to the instance with admin as username which is not working for me after the user data script execution.

cn flag
What's all that content-type stuff? All the user data scripts I've seen don't have that... Also there's a ton of spaces and things that haven't copied well into the question - can you reformat?
cn flag
Huh, TIL: https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.