Feature #8420
closedHow to use my own keypair instead of foreman's created ?
Description
How to use my own specified keypair instead of default created by foreman while provisioning a new instance?
Please let me know if that posible. I am not able to login to new ec2 instaces after it is getting created.
Tried with copying my public key to user's authorize-keys by passing it via user-data. But that did not work as well.
Any pointer here will be a great help for me.
Regards,
Biswajit
Updated by Dominic Cleal almost 10 years ago
- Is duplicate of Feature #8319: ec2 compute sould be able to use existing ssh keys added
Updated by Dominic Cleal almost 10 years ago
- Status changed from New to Duplicate
#8319 covers this request already I think. If you want to add your own, best to do it in user data or a finish template. If that's not working, it would be best to debug it a bit and e-mail the foreman-users list or ask on #theforeman with more details if you're still stuck, as it's probably an issue in your template or image.
Updated by Biswajit Banerjee almost 10 years ago
Thank, Dominic. I will definately look into other things around like template or image.
Here is the user-data I am using ,
#!/bin/bash -ex
useradd -d /home/demo -s /bin/bash -c 'demo user' demo
echo demo:***** | chpasswd
mkdir -p /home/demo
chown -R demo:root /home/demo
mkdir -p /home/demo/.ssh
touch authorized_keys
echo 'PUBLIC KEY' >> /home/demo/.ssh/authorized_keys
chmod 600 /home/demo/.ssh/authorized_keys
/usr/bin/perl -p -i -e "s/PermitRootLogin no/PermitRootLogin yes/" /etc/ssh/sshd_config
echo " User demo has been set , please try login with user-demo."
echo 'Hello world - I just executed user-data!' > /root/helloworld
Anything wrong here ?
Updated by Dominic Cleal almost 10 years ago
Permissions on /home/demo/.ssh might need to be 0700, but I'm guessing unless you can get the logs from sshd and attempted logins.