AWS Keypairs when creating host

I’m relatively new to using Rancher (and containers in general) so forgive my lack of experience here. I’ve been creating hosts via Rancher GUI in AWS pretty easily, but Rancher creates keypairs for those EC2 instances that I’d have to download manually to ssh to the hosts if need be. We already have a shared keypair that we use for other EC2 instances, that i’m trying to see if i can launch a host using that. My syntax seems correct and I have the file uploaded to the rancher/server container, but keep getting this message

Error with pre-create check: “There is no keypair with the name dlvr-devops. Please verify the key name provided.”

Below is the example CLI script i’m using:

#!/bin/bash
./rancher host create --driver amazonec2 \
 --amazonec2-access-key access-key \
  --amazonec2-secret-key secret-key \
   --amazonec2-region us-west-2 \
    --amazonec2-vpc-id vpc-name \
     --amazonec2-security-group rancher-machine \
      --name lab-pdx-2 \
       --amazonec2-instance-type t2.micro \
        --amazonec2-ssh-keypath /tmp/dlvr-devops   \
         --amazonec2-keypair-name dlvr-devops
  1. Is this even possible what I’m trying to-do?
  2. Is my syntax off?
  3. If I can’t do this, anyone have an example how they’re managing the individual key-pairs that are generated per host without having to manually download?

docker-machine ends up running inside the server container, not your desktop. So /tmp/dvlr-devops does not exist there.

rancher ssh <host> will automatically download and use the key associated with the machine, so you don’t necessarily have to manually download it.

To actually use your own key you can’t really use the built-in machine driver. It’s not really much harder to just create Instances on your own though through EC2 (or other automation) and run the custom add host registration command as the userdata script. You can also combine this with an autoscaling group to spin up more/less as needed.