0

I have 3 instances on GCP all ubuntu. I try to ssh from the private IPs in each as soon as I start the machines and they work fine but after some time they start throwing errors.

shiv1499@ansiblemaster:~$ ssh 10.128.0.5
Last login: Tue Sep 17 15:42:19 2019 from 10.128.0.3
shiv1499@target2:~$

shiv1499@ansiblemaster:~$ ssh 10.128.0.4
Last login: Tue Sep 17 15:42:09 2019 from 10.128.0.3
shiv1499@target1:~$

shiv1499@ansiblemaster:~$ ssh 10.128.0.4
shiv1499@10.128.0.4: Permission denied (publickey).

shiv1499@ansiblemaster:~$ ssh 10.128.0.5
shiv1499@10.128.0.5: Permission denied (publickey)
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940

1 Answers1

0

This problem usually is caused by the ssh-agent.

When it happen, try the following:

eval $(ssh-agent)
ssh-add YOUR_KEYS_PATH # maybe not necessary

The brute solution, is force the ssh connection to use the certificate:

ssh -i your_priv_key user@ip
alessiosavi
  • 131
  • 5