EC2's Commands
EC2's Commands
Change hostname
1. Edit /etc/hosts
2. run
3. reboot
2. Use the adduser command to add a new user account to an EC2 instance
(replace new_user with the new account name). The following example creates an
associated group, home directory, and an entry in the /etc/passwd file of the instance.
The home directory might not be created by default in some configurations. Verify that the
home directory was created before continuing.
Note: If you add the new_user to an Ubuntu instance, then include the --disabled-
password option to avoid adding a password to the new account:
3. Change the security context to the new_user account so that folders and files you
create have the correct permissions:
$ sudo su - new_user
Note: When you run the sudo su - new_user command, the name at the top of the
command shell prompt changes to reflect the new user account context of your shell
session.
4. Create a .ssh directory in the new_user home directory:
$ mkdir .ssh
5. Use the chmod command to change the .ssh directory's permissions to 700. Changing
the permissions restricts access so that only the new_user can read, write, or open
the .ssh directory.
6. Use the touch command to create the authorized_keys file in the .ssh directory:
$ touch .ssh/authorized_keys
7. Use the chmod command to change the .ssh/authorized_keys file permissions to 600.
Changing the file permissions restricts read or write access to the new_user.
2. Paste the public key into the .ssh/authorized_keys file and then press Enter.
Note: For most Linux command line interfaces, the Ctrl+Shift+V key combination pastes the
contents of the clipboard into the command line window. For the PuTTY command line
interface, right-click to paste the contents of the clipboard into the PuTTY command line
window.
3. Press and hold Ctrl+d to exit cat and return to the command line session prompt.
Verify that the new user can use SSH to connect to the EC2
instance
1. Run the following command from a command line prompt on your local computer:
$ ssh -i /path/new_key_pair.pem
new_user@public_dns_name_of_EC2_Linux_instance
To connect to your EC2 Linux instance using SSH from Windows, follow the steps
at Connect to your Linux instance from Windows using PuTTY.
Note: If you receive errors when trying to connect, then see Troubleshoot connecting to your
instance.
2. Run the id command from the instance's command line to view the user and group
information created for the new_user account:
$ id
# icon:
1 mkdir .ssh
2 chmod 700 .ssh
3 touch .ssh/authorized_keys
The above will change PmiProduction string with Production in the filebeat.yml file
2. add to fstab:
3. reboot
# in Prod:
sudo mount -t nfs -o
nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-
590.efs.eu-west-1.amazonaws.com:/ /mnt/prod-efs
This will create a /integration_shared/ ln under /opt/ and will point to efs related folder
unlink /opt/integration_shared