I have a bash script
#!/bin/bash
scp -r some_directory remote_host:~
which I made executable with chmod u+x
. The remote_host has been defined in my .ssh/config as follows:
Host remote_host
HostName ec2-x-xxx-xx-xxx.eu-central-1.compute.amazonaws.com
User ubuntu
IdentityFile ~/path_to_pem_file/pem_file.pem
IdentitiesOnly yes
when I call scp -r some_directory remote_host:~
or ssh remote_host
it works without problems to access the remote machine via ssh. However inside the bash script it doesn't work. I get the following error:
ssh: Could not resolve hostname mochacle: Name or service not known
lost connection
ssh: Could not resolve hostname mochacle: Name or service not known
ssh: Could not resolve hostname mochacle: Name or service not known
irrespective of whether I sudo the execution of the script or not.