Feature #17015
closedAdd ability to get private keys or use existing key pairs when provisioning on EC2
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1333604
Description of problem:
After configuring AWS EC2 as a compute resource and provisioning a virtual machine, the user cannot SSH onto the virtual machine because foreman has generated an SSH key pair itself used to provision the machine.
The user should be able to view and download these keys through the Foreman web gui (as a minimum).
They should also be able to use existing pairs already configured in AWS or should be given the option to generate their own.
This entails a potential security risk as it is not obvious if a keypair is generated per virtual machine OR per compute resource.
Here is the work around to get the key to SSH to the machine:
1) Run the command hammer compute-resources list
2) Take note of the compute-resource (can vary depending on how many you have or have had, the number increments even after they have been deleted).
3) Now run su to the postgres user, CD to tmp and run the following command:
echo 'select secret from key_pairs where compute_resource_id = <Compute Resource ID>;' | psql -d foreman -t | sed -e 's/^[ \t]*//'| sed 's/+$//' | sed "s/[[:blank:]]*$//" > /tmp/<Key Pair Name>.pem
- Where the Compute Resource ID and Key Pair Name have been replaced.
- You can verify the integrity of key using this command: openssl rsa -in <Key Pair Name>
If the key is not displayed, or it asks you for a pass phrase, there is an issue with the key.
4) You should have a pem file which can now be used to log into your EC2 machine. Depending on your AMI, try the following command:
ssh -i <Key Pair Name>.pem ec2-user@<EC2 VM Hostname or IP>
For regular RHEL AMI, the initial user is ec2-user, it may be different depending on the AMI used.
Steps to Reproduce:
1. Setup AWS Compute Resource and users, provision a VM.
2. > Try to connect to the machine via SSH, not possible without key.
3. Run work around to get key, but it should be easier!
Actual results:
Key pairs are not visible to user unless they run database queries.
Expected results:
User should be able to get their key pair easily.
Updated by Ondřej Pražák about 8 years ago
- Subject changed from AWS Compute Resource Enhancement: Add ability to get private keys or use existing key pairs when provisioning on EC2 to AWS Compute Resource Enhancement: Add ability to get private keys or use existing key pairs when provisioning on EC2
- Target version set to 115
Updated by Ondřej Pražák about 8 years ago
- Related to Feature #8319: ec2 compute sould be able to use existing ssh keys added
Updated by Dominic Cleal about 8 years ago
- Subject changed from AWS Compute Resource Enhancement: Add ability to get private keys or use existing key pairs when provisioning on EC2 to Add ability to get private keys or use existing key pairs when provisioning on EC2
- Description updated (diff)
Very hard to read with code formatting!
Updated by Shlomi Zadok about 8 years ago
- Assignee set to Shlomi Zadok
- Target version changed from 115 to 1.4.2
Updated by Marek Hulán about 8 years ago
- Target version changed from 1.4.2 to 1.4.4
Updated by The Foreman Bot about 8 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/4024 added
Updated by Marek Hulán almost 8 years ago
- Target version changed from 1.4.4 to 1.10.1
Updated by Ohad Levy almost 8 years ago
- Related to Feature #17841: expose key_pair info via API added
Updated by Shlomi Zadok almost 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 59e7136a2ac14317071d9ae86d7f0472e6413c86.
Updated by Dominic Cleal almost 8 years ago
- Translation missing: en.field_release set to 209
Updated by Dominic Cleal over 7 years ago
- Related to Bug #19631: ActiveRecord::RecordNotSaved when deleting compute resources with key pairs added