Ubuntu – Accessing a remote file via ssh on Ubuntu 12.04

sshtext;

I have a text file on one of my computers that is running 12.04. I was planning to use ssh to allow for another computer to read this text file. The issue is that the system that I am working with is basically logging some information on this text file at real time. I need for the computer that is going to read this text file, to read the text file at real time as well.

I am not savvy at all with ssh, but I am familiar with ubuntu. If anyone can provide some insight as to how to do this, or if it is even possible to read this text file at real time while another system is logging info it would be greatly appreciated.

Thank you.

Best Answer

What do you mean by "read" the file? If you just want to echo the contents back to the STDOUT, then this should do it.

ssh user@remoteHostName 'tail -f /myDirectory/myFile.txt'

That should work if you have SSH set up properly, "user" is a valid user on your remote host, and the -f flag on the tail command will allow it to view a file as it grows.