![]() Note that we can do the same for "ubuntu" or "ec2-user" for AWS instance with the inventory file (./hosts) like this:ģ.93.171.48 ansible_user=ubuntu ansible_ssh_private_key_file=/Users/kihyuckhong/.ssh/einsteinish.pem Note that by specifying inventory "-i prod", Ansible grabs the file under the "prod" folder and performs "ping" using the ip address with key info in the inventory file. Now, using Ansible we want to check the connection to the production server on AWS. On our local machine, we have "inventory" file under prod folder:ĥ2.53.215.28 ansible_user=k ansible_ssh_private_key_file=/Users/k/.ssh/id_rsa Though it is too early to see how Ansible works, for those who are eager to learn Ansible, I'll show a quick sample usage of Ansible. Now, we're able to login to aws with the same user ssh 54.67.48.10 Ssh-rsa AAAAB3Nza.fPWGjjQfJ7 may want to switch user:group Then, put local public key, ~/.ssh/id_rsa.pub, into aws's /home/k/.ssh/authorized_keys: Here are the steps to follow in either case.įirst, we want to create a user k using the key that's downloaded from aws, ssh -i bogo.pem aws instance ![]() $ ssh -i /Users/khong/.ssh/myKey.pem Permanently added ',3.93.147.99' (ECDSA) to the list of known hosts.ĥ package(s) needed for security, out of 7 available For example, for an instance we created with a key pair name, myKey: If that's what we want to, we still can follow the steps described below.īasically, we should give our public key to the AWS instance: append "id_rsa.pub" to "/home/username/.ssh/authorized_keys" file (we may well see public key pair of *.pem file already there). If we insist on using existing user name (most likely "ubuntu") which we access the AWS instance, we can do it by specifying the user name when we issue Ansible command "-u username". On my desktop, I'm logged in as a user k, and I want to login to aws instance with same user name. Our public SSH key should be located in authorized_keys on remote systems. Before we get started, we need to understand how Ansible communicates with remote machines over SSH.īy default, Ansible 1.3 and later will try to use native OpenSSH for remote communication when possible.Īnsible, by default, assumes we're using SSH keys.Īnsible has a default inventory file ( /etc/ansible/hosts) used to define which remote servers it will be managing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |