I'm logged in my local machine. From here I invoke a script in the remote machine. Note that the script is placed in the remote machine it has to be run there. This I can do from my local machine by the following command

ssh myusername@remoteCluster '/home/projects/runCluster.sh'

This works perfectly and it writes down a logfile.log in the remote machine in directory /home/projects/. To view this I've to open another terminal, do an ssh to the remoteCluster, navigate the directory and check the logfile.

My question was whether its possible to dynamically copy(scp) the logfile to my local machine from where I invoked the command

ssh myusername@remoteCluster '/home/projects/runCluster.sh'

I inserted the following command inside runCluster.sh

scp logfile.log myusername@mylocalmachine:~/projects but I get the following message

ssh: connect to host mylocalmachine port 22: No route to host lost connection

I hope I could put across my question clearly. Any help in this regard would be greatly appreciated.

Cheers Johny


Based on what you describe my guess would be that your local machine does not have an SSH daemon running.

You can check this with:

service sshd status

on RHEL 5 or 6 and

systemctl status sshd

on RHEL 7.

If you want the remote machine to be able to connect back you need to start (and optionally configure) the SSHD daemon on the local machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.