Reputation: 321
So I'm currently working on a load balancing python script. In this script I will need to update a file on a server. My plan is to have my python script call a bash script.
In that bash script I'd like to ssh into the server, execute an awk command on a file, then logout.
I can currently ssh into this server manually, because I've set up an ssh key (using Google Cloud Platform). But when I try to run a bash script that only executes
'ssh username@externalIP'
I get the error: Permission denied (publickey)
What am I missing here?
Upvotes: 3
Views: 1981
Reputation: 2033
Probably your private key is in your home directory and python is spawning the bash process as a limited user, try changing your script to include the private key explicitly, if still doesn't work you will have to copy the key and change its permission
To explicitly add the private key:
ssh -i /path/to/private/key user@host
Upvotes: 1