I need to read a remote file with logs from a remote host via SSH

I need to read a remote file with logs from a remote host via SSH What is the most convenient way to do it if I have ssh access to the log folder ?


Solution 1:

Why do anything complicated? The following should work fine..

ssh server "cat /path/to/file"

If you want paging..

ssh server "cat /path/to/file" |less

Solution 2:

I use:

ssh -t user@host "less ~/path/to/log.file"

The -t causes ssh to allocate a terminal, which allows you to interact with less as if it were running locally, including searching/scrolling/tailing, all without streaming the whole remote file to the local computer.

Solution 3:

The most convenient I would say is sshfs.

Solution 4:

Vi, nano, less, etc.

Solution 5:

I think you should definitely use a program on the remote host and open the file there, instead of downloading the file and opening on the client side / your side.

As far as I know Linux editing/reading tools such as 'vi' or 'less' read the file line by line, therefore you don't have to open the whole log file, you just open the parts and transfer them through ssh as you read. Other operating systems have similar programs but I can't recall the name of any.

I don't know if there is a way to load the file part-by-part to a client reader on SSH though.