EC2 instance with custom ssh key pair
Following howto describes how to build EC2 instance with custom user and corresponding ssh public key.
User will be created:
- as a member of wheel group
- with /bin/bash shell
- ALL=(ALL) NOPASSWD:ALL sudo rights.
1. Create key pair
To create key pair, execute ssh-keygen command. By default, keys will be created into ./.ssh/ directory
2. EC2 instance deployment
Deploy EC2 instance in standard way. In Step 3, in the bottom paste following script.
Replace name with proper username and public key using previously generated id_rsa.pub
3. Default key pair
You can still using existing key pairs to allow ec2-user to log in
4. EC2 deployment check
When EC2 instance will be deployed, proceed to test phase
5. Establish ssh session using IPv4
obsd$ ssh 188.8.131.52
6. Establish ssh session using IPv6
obsd$ ssh 2a05:d014:60e:7100:81f0:fe14:570a:e305