Infrastructure at your Service

Mouhamadou Diaw

Managing My Amazon Web Services Redhat Instance

By November 15, 2016 Cloud No Comments

In a precedent Blog I talked about how to create an AWS linux instance. Some questions can be: How to create a new user and to connect with, how to transfert files from my workstation, how to connect to my oracle instance from my workstation and so on.
In this blog I am going to deal with some basic but useful  administration tasks.
Changing my hostname
One thing we will probably do is to change the hostname. Indeed the linux is built with a generic hostname. Changing hostname include following tasks
Update /etc/hostname with the new hostname

[[email protected] etc]# vi hostname
[[email protected] etc]# cat /etc/hostname
[[email protected] etc]#

Update /etc/hosts

[[email protected] ORCL]# cat /etc/hosts  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Update our /etc/sysconfig/network with the HOSTNAME value

[[email protected] sysconfig]# cat network
[[email protected] sysconfig]#

To keep the change permanent we have to add in /etc/cloud/cloud.cfg file the line preserve_hostname: true

[[email protected] cloud]# grep   preserve_hostname cloud.cfg
preserve_hostname: true
[[email protected] cloud]

 The last step is to reboot the server

[[email protected] cloud]# reboot
Using username "ec2-user".
Authenticating with public key "imported-openssh-key"
Last login: Mon Nov 14 03:20:13 2016 from
[[email protected] ~]$ hostname

Creating a new user and connecting with
User creation is done by useradd as usual. But to be able to connect with this user we have to do some tasks. Suppose the new user is oracle.
With oracle we have to create a .ssh directory and adjust permissions on it

[[email protected] ~]# su - oracle
[[email protected] ~]$ pwd
[[email protected] ~]$ mkdir .ssh
 [[email protected] .ssh]$ chmod 700 .ssh

And then let’s create an authorized_keys file

[[email protected] ~]$ touch .ssh/authorized_keys
[[email protected] ~]$ cd .ssh/
[[email protected] .ssh]$ vi authorized_keys
[[email protected] .ssh]$ chmod 600 authorized_keys

The last step is to copy the content of our public key (we used for user ec2-user). Remember that we have created a key pair when we built our linux box (see corresponding blog ) into the authorized_keys under /home/oracle/.ssh/authorized_keys

cd /home/ec2-user/
cd .ssh/
cat authorized_keys >> /home/oracle/.ssh/authorized_keys

And now connection  should be fine with my new user from my workstation using public DNS and putty.
Tranferring files from my workstation to the AWS instance
One need might be to transfer files from our local workstation to the our AWS instance. We can use WinSCP, we just have to use the key by importing our putty session (we already used to connect) into WinSCP and after we can connect. Launch WinSCP and use Tools option.

And then select the session we want to import and we should connect with WinSCP
Connecting to my oracle instance from my workstation
I have installed my oracle software and my database and listener are running. How to connect from my workstation? It is like we usually do. We just have to allow connection on the database port (here I am using the default 1521). Security Groups option is used for editing the inbound rules.
Using Add Rule, we can allow connection on port 1521. Of course we can filter the source for the access.

And using the DNS of my instance I can connect.For this example I am connecting to an oracle express instance XE.

You have AWS documentation here








Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Mouhamadou Diaw
Mouhamadou Diaw