Feature #8420
closed
How to use my own keypair instead of foreman's created ?
Added by Biswajit Banerjee about 10 years ago.
Updated about 10 years ago.
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
Related issues
1 (1 open — 0 closed)
- Is duplicate of Feature #8319: ec2 compute sould be able to use existing ssh keys added
- 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.
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 ?
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.
- Assignee set to Shlomi Zadok
Also available in: Atom
PDF