Access issues with Google Cloud Instances


I an new to gce and trying to install ansible on a node and trying to ping another node. I am  using --ask-pass --ask-become-pass to exchage passwords (I am using same user and root password across all the nodes) but for some reason the above process is failing.

Can you please tell me where I am doing mistake

  • post-author-pic
    Matthew U

    Is SSH/port 22 allowed between instances? Are you able to SSH from one instance to another? I was able to find an Ansible-specific issue/resolution to this error at the below link:

    Does one of the below solutions for the above link work for you assuming that port 22 is enabled between instances?

    "I have just found out the reason, I cannot connected.

    There was an error in my config file in .ssh folder which make the ssh go to a different router rather then the on-site one.

    I need to add ansible_ssh_pass=<mypassword> ansible_ssh_user=<myusername> next to the host IP in the /etc/ansible/hosts."

  • post-author-pic
    Aditya P

    1. Yes, i doublechecked firewall settings and it looks good.
    2. I tried to follow the other steps which where shown in the link, but no luck.
    3. I am sure that issue is with ssh (i couldnt ssh into other instance using ssh keys)
    4. Will update you, if I could resolve.
    Thanks again   @mulasien  @mattulasien 

  • post-author-pic
    Aditya P

    I also tried to enable root login on target host but dint work for me

  • post-author-pic
    Ben L

    You mentioned that you're connect using a username/password. By default doesn't Google use SSH keys? 
    Did you make changes to the SSH settings?

    Just some things that I would try:

    1.) Verify that SSH works with SSH key (because this is the default)
    -> List off your instances to ensure you have the correct name.
    $ `gcloud compute instances list`
    -> Connect into the instance using gcloud
    $ `gcloud compute ssh linux-user-name@instance-name`
    -> NOTE: you can also add the --dry-run flag to view the SSH command being run.
    $ `gcloud compute ssh linux-user-name@instance-name --dry-run`

    If that doesn't work, you may have a broken SSH configuration. Start by undoing any changes and try again.
    If these work, then connecting via SSH works using an SSH key.
    You could upload your SSH key as project metadata.
    $ `gcloud compute project-info add-metadata --metadata-from-file ssh-keys=[LIST_PATH]`
    Then in Ansible you could set the path to your SSH key by setting the private_key_file property.

    If you need to use a username/password
    2.) Verify that SSH works with username/password
    -> List off your instances to ensure you have the correct name.
    $ `gcloud compute instances list`
    -> Using the external IP address from the list above, attempt to connect via ssh
    $ `ssh linux-user-name@instance-external-ip-address`

    If that doesn't work, the issue could be related to your username, password, or the SSH configuration.
    If it does work, the issue is likely with Ansible. At this point, try using the verbosity flags to view the commands being run, and see if maybe they're not being called correctly. If you can extact the command that Ansible is running, you can start debugging it.

    Ensure the IP address is set correctly. Being ephemeral, they can change.
    Ensure the module is trying to connect with username and password, and not via key.

    These sorts of issues can be tricky. One typo can break everything. I've been there! Keep ruling out issues one at a time. Good luck! :D

  • post-author-pic
    Aditya P

    Hi  @sowhelmed
    I am stuck at the first steps itself.

Looking For Team Training?

Learn More