Tuesday 6 August 2019

AWS - Changing host name on EC2 machine OEL 7.6

Senerio Priview:


  • EC2 machine OEL 7.6  64 bit
  • Default hostname p-10-0-0-109.ap-south-1.compute.internal
Solution : 
  • /etc/hostname/
  • /etc/cloud/cloud.cfg 

Unmark
# - set_hostname
# - update_hostname

  • reboot machine
  • Login EC2 using private key




vi /etc/hostname/

[root@ip-10-0-0-109 ~]# cat /etc/hostname
#ip-10-0-0-109.ap-south-1.compute.internal
OEL_7.6
[root@ip-10-0-0-109 ~]#


#######################################################################
 change in cloud.cfg file


vi /etc/cloud/cloud.cfg


# COMMNENT OUT

# - set_hostname
# - update_hostname


users:
 - default

disable_root: 1
ssh_pwauth:   0

mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
resize_rootfs_tmp: /dev
ssh_deletekeys:   0
ssh_genkeytypes:  ~
syslog_fix_perms: ~

cloud_init_modules:
 - migrator
 - bootcmd
 - write-files
 - growpart
 - resizefs
# - set_hostname
# - update_hostname
 - update_etc_hosts
 - rsyslog
 - users-groups
 - ssh

cloud_config_modules:
 - mounts
 - locale
 - set-passwords
 - yum-add-repo
 - package-update-upgrade-install
 - timezone
 - puppet
 - chef
 - salt-minion
 - mcollective
 - disable-ec2-metadata
 - runcmd

cloud_final_modules:
 - rightscale_userdata
 - scripts-per-once
 - scripts-per-boot
-- INSERT --
###################################

[root@ip-10-0-0-109 ~]# vi /etc/cloud/cloud.cfg
[root@ip-10-0-0-109 ~]# reboot

####

login again on putty using private key

login as: ec2-user
Authenticating with public key "imported-openssh-key"
Last login: Mon Jul 15 06:52:17 2019 from 103.60.104.4
[ec2-user@OEL_7 ~]$ hostname
OEL_7.6
[ec2-user@OEL_7 ~]$


No comments:

Post a Comment