EC2 users (keypair)

Setting up EC2 the default login is root with a pub/priv key generated on the EC2 site as keypairs. I do not want to log in a root directly and disable this on the server. After a bit of searching I found this site that explained the process.

The problem with this method is there are a few errors and also once you do this you are screwed, because you cannot su to root!!!.

So new procedure is below

1) Change the root password!!!!

2) follow these steps

adduser des
(Need a password here)

ssh-keygen -b 1024 -f des -t dsa
(Need a passphrase here)

cd ~des
mkdir .ssh
chmod 700 .ssh
chown des:des .ssh

cp /root/des* .ssh/
chown  des:des .ssh/des
chown  des:des .ssh/
cat /root/ > .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
chown des:des .ssh/authorized_keys

test if it works

ssh -i /home/des/.ssh/des -l des

copy key to local machine. Easiest is to print it out and copy it to a text file on local machine as des.pem

cat .ssh

That’s it. Once this works fine, then change the

PermitRootLogin no

Leave a comment

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s