This question already has an answer here:
I am having some trouble running a script to ssh to a remote server. If I simply ssh from the command line I have no trouble reaching the server, but when I run a script to do this I get an error, "Name or service not knownname". I have added the IP address and host name to /etc/hosts and that did not help.
My script is simply:
#!/bin/bash ssh username@hostname
Am I doing something wrong? Obviously I don't need a script just for this, but I'm going to add commands to execute once I get this working.