# 'knife ec2 server create' through gateway hangs, but 'knife bootstrap' works fine

**URL:** <https://discourse.chef.io/t/knife-ec2-server-create-through-gateway-hangs-but-knife-bootstrap-works-fine/6181>\
**Category:** Chef Infra (archive)\
**Created:** [January 19, 2015, 5:54pm UTC](https://discourse.chef.io/t/knife-ec2-server-create-through-gateway-hangs-but-knife-bootstrap-works-fine/6181 "2015-01-19T17:54:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjbottaro](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cjbottaro](https://discourse.chef.io/u/cjbottaro)\
**Post date:** [January 19, 2015, 5:54pm UTC](https://discourse.chef.io/t/knife-ec2-server-create-through-gateway-hangs-but-knife-bootstrap-works-fine/6181/1 "2015-01-19T17:54:16Z")

</div>

I followed the Server Fault answer here:

> <https://serverfault.com/questions/641951/knife-cant-ssh-into-newly-instantiated-ec2-server>

But it still doesn't work.

The instance is launched fine, but it waits forever on the "waiting for  
sshd" step.

The weird part is that if I run knife bootstrap directly on the private ip  
(using the --ssh-gateway) option, it works fine.

Here is the knife command I'm using:

bundle exec knife ec2 server create   
--environment edge   
--node-name edge-db-e-clients-01   
--subnet subnet-xxx   
--flavor m3.medium   
--image ami-xxx   
--security-group-ids sg-xxx   
--iam-profile node   
--ssh-user ubuntu   
--ssh-key provisioner   
--ssh-gateway [ubuntu@bastion.blah.com](mailto:ubuntu@bastion.blah.com)   
--server-connect-attribute private\_ip\_address   
--no-host-key-verify   
--ebs-size 50   
--ephemeral /dev/sdb,/dev/sdc,/dev/sdd,/dev/sde   
--json-attributes '{"route53":{"value\_src":"local\_ipv4","type":"A"}}'   
--run-list recipe[aw\_base::default],recipe[aw\_base::auto\_dns]

The output of that gets stuck here:

Waiting for sshd access to become available  
DEBUG: Using ssh gateway [ubuntu@bastion.blah.com](mailto:ubuntu@bastion.blah.com) from knife config

Here is the knife bootstrap command that works fine through the gateway:

bundle exec knife bootstrap 10.x.x.x   
--environment edge   
--node-name edge-db-e-clients-01   
--ssh-user ubuntu   
--ssh-gateway [ubuntu@bastion.blah.com](mailto:ubuntu@bastion.blah.com)   
--sudo   
--json-attributes '{"route53":{"value\_src":"local\_ipv4","type":"A"}}'   
--run-list recipe[aw\_base::default],recipe[aw\_base::auto\_dns]

Any ideas? Thanks for the help.

---

<div class="post-metadata">

**Author:** ![cjbottaro](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cjbottaro](https://discourse.chef.io/u/cjbottaro)\
**Post date:** [January 19, 2015, 6:21pm UTC](https://discourse.chef.io/t/knife-ec2-server-create-through-gateway-hangs-but-knife-bootstrap-works-fine/6181/2 "2015-01-19T18:21:29Z")

</div>

Nevermind, figured it out (by reading the source of course). `knife ec2 server create` doesn't honor your `.ssh/config` file, so I had to manually  
specify the right port and identity file for the ssh gateway:

--ssh-gateway ubuntu@bastion.blah.com:2222  
--ssh-gateway-identity /path/to/correct/identity/file

With those two options corrected, it works now.

On Mon, Jan 19, 2015 at 11:54 AM, Christopher J. Bottaro \<  
[cjbottaro@academicworks.com](mailto:cjbottaro@academicworks.com)\> wrote:

> I followed the Server Fault answer here:  
> [amazon ec2 - Knife can't ssh into newly instantiated EC2 server - Server Fault](http://serverfault.com/questions/641951/knife-cant-ssh-into-newly-instantiated-ec2-server)
> 
> But it still doesn't work.
> 
> The instance is launched fine, but it waits forever on the "waiting for  
> sshd" step.
> 
> The weird part is that if I run knife bootstrap directly on the private ip  
> (using the --ssh-gateway) option, it works fine.
> 
> Here is the knife command I'm using:
> 
> bundle exec knife ec2 server create   
> --environment edge   
> --node-name edge-db-e-clients-01   
> --subnet subnet-xxx   
> --flavor m3.medium   
> --image ami-xxx   
> --security-group-ids sg-xxx   
> --iam-profile node   
> --ssh-user ubuntu   
> --ssh-key provisioner   
> --ssh-gateway [ubuntu@bastion.blah.com](mailto:ubuntu@bastion.blah.com)   
> --server-connect-attribute private\_ip\_address   
> --no-host-key-verify   
> --ebs-size 50   
> --ephemeral /dev/sdb,/dev/sdc,/dev/sdd,/dev/sde   
> --json-attributes '{"route53":{"value\_src":"local\_ipv4","type":"A"}}'   
> --run-list recipe[aw\_base::default],recipe[aw\_base::auto\_dns]
> 
> The output of that gets stuck here:
> 
> Waiting for sshd access to become available  
> DEBUG: Using ssh gateway [ubuntu@bastion.blah.com](mailto:ubuntu@bastion.blah.com) from knife config
> 
> Here is the knife bootstrap command that works fine through the gateway:
> 
> bundle exec knife bootstrap 10.x.x.x   
> --environment edge   
> --node-name edge-db-e-clients-01   
> --ssh-user ubuntu   
> --ssh-gateway [ubuntu@bastion.blah.com](mailto:ubuntu@bastion.blah.com)   
> --sudo   
> --json-attributes '{"route53":{"value\_src":"local\_ipv4","type":"A"}}'   
> --run-list recipe[aw\_base::default],recipe[aw\_base::auto\_dns]
> 
> Any ideas? Thanks for the help.
