We will be customizing this image in stages and each time, saving it as an Amazon Machine Image (ami). If we make all the customizations in one go, there is the danger that we will make a mistake and be unable to log in to the instance.
We assume at this point that you are logged in as root to the Debian instance you just created (see the previous section if not). Type or paste the following commands one by one on the instance (don't copy and paste them all as a single block, it won't work):
## want to get a root prompt. yes, this is bad form. sudo bash apt-get -y update apt-get -y upgrade apt-get -y install emacs less vim
Here, emacs
and less
are packages that I find it hard to navigate a machine without. The option -y
avoids Aptitude prompting to confirm the install. When we create the cluster, there will be a "head node" called "master" that acts as the server for the GridEngine and NIS services. (NIS is something that used to be called YP, or yellow pages, that enables us to sync various important system files across a cluster). We will be setting up the image to "look like" the master, but the same image will be used to create the nodes. If we want it to be a node, we will put something in the EC2 "user data" to tell it so, and scripts on the image will set it up as a node. In order for the master and nodes to be able to securely ssh to each other, we will set up the image with an ssh key that allows. this. Type the following command on the instance. Make sure you are root when you do this; if you did sudo bash
above you should still be root.
ssh-keygen
The command ssh-keygen
will prompt you for various things; just press enter three times. Next do as follows:
cd cp -r /home/admin/.ssh . (echo; cat .ssh/id_rsa.pub) >> .ssh/authorized_keys
This will mean that different instances spawned from this image will be able to ssh to each other as root. We'll be logging into this machine as root directly, so make sure the file /etc/ssh/sshd_config says:
PermitRootLogin without-password
(the default in previous versions of Debian was no
).
Verify that the instance can ssh to itself:
ssh localhost
(this command should succeed).
Next, we want to make an image. To do this we need to stop the instance, so from your local machine, stop it: something like
ec2stop i-7877a019
Now create an image from the instance. You have to think of a name for it (the -n
option): from the client, do as follows:
# ec2cim i-7877a019 -n 'customized_phase_1_try1' IMAGE ami-8eaf37e7
In order to create an instance from this you will need to remember the AMI-ID (ami-8eaf37e7
in this case), but if you forget it, just type ec2dim
and it will list all the images you have made. It may take a few minutes for this AMI (Amazon Machine Image) to be ready; wait until you can type something like ec2dim ami-8eaf37e7
and it says available
rather than pending
.
Previous: Creating a Debian Linux Instance
Next: Customizing your Image (Phase 2)
Up: Kluster Wiki
Wiki: CreatingInstance
Wiki: CustomizingImage2
Wiki: Home
added 8.8.8.8 to /etc/resolv.conf because Amazon nameserver did not work
"This will mean that different instances spawned from this image will be able to ssh to each other as root. We'll be logging into this machine as root directly, so edit the file /etc/ssh/ssh_config so it says
PermitRootLogin without-password"
-->It should be sshd_config or?
I think you're right. I'll try to change it.
Dan
On Thu, Jun 4, 2015 at 5:25 PM, Joseph D josephd112@users.sf.net wrote: