I followed the railscasts and with basic configurations
such as image_id: ami-3f32ac3e
(Ubuntu Server 12.04.3 LTS 64 bit), app_name: myapp
, app_user: jashwant
, I tried to deploy with rubber.
Everything went smooth. I now have a running instance, but at the end I am getting
Trying to enable root login
* 2013-11-09 17:03:33 executing `rubber:_ensure_key_file_present'
* 2013-11-09 17:03:33 executing `rubber:_allow_root_ssh'
* executing "sudo -p 'sudo password: ' bash -l -c 'mkdir -p /root/.ssh && cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
servers: ["54.238.122.222"]
** Failed to connect to 54.238.122.122, retrying
* 2013-11-09 17:03:37 executing `rubber:_ensure_key_file_present'
* 2013-11-09 17:03:37 executing `rubber:_allow_root_ssh'
* executing "sudo -p 'sudo password: ' bash -l -c 'mkdir -p /root/.ssh && cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
servers: ["54.238.122.122"]
You can see the error here
I concluded from here that, I need to set :initial_ssh_user
in config/deploy.rb
I already saw,
set :user, 'root'
set :password, nil
in config/deploy.rb
So, I added set :initial_ssh_user, 'ubuntu'
. But the error remains the same.
If I change set :user, 'root'
to set :user, 'ubuntu'
, then I get
Trying to enable root login
* 2013-11-09 17:13:48 executing `rubber:_direct_connection_54.238.122.122_411'
* executing "echo"
servers: ["54.238.122.122"]
** Failed to connect to 54.238.122.122, retrying
Things I have checked after googling:
It's not happening because Amazon instance is still starting. I have waited long after the instance has started. Also, I get the same error when I do ALIAS=production cap rubber:refresh
I am able to successfully log in to this new instance via ssh (providing username as ubuntu
). So, key file is okay.
I have already added the key with ssh-add
Key file in .ec2
directory does not have .pem
extension.
I do not have duplicate entries in my etc/hosts
on Amazon instance.
It turned out that rubber wasn't able to read from private key. I fixed that and it worked.