Can we connect another server

Assume I am on hostname 111
and want to connect hostname 222 in order to check some file being connected with 111

can this be possible, being on one hostname can we see file of another host and on both host I have access.

This is the requirment I need to implement in a script that I am writing a script which will be on one host or server i.e 111 but its requirement is it check the same file on the another server i.e 222.

Please help.
I need to impelement it in my script.

Thanking you in advance.

what to check? content, file size, or others?

For example, check if the file is same or not on 111 and 222.

have ssh set between 111 and 222:

diff <(ssh user@host222 md5sum /path/file) /path/file

I need to search for a file and if file found need to search a string from it. But from another host

In order to work on a remote file, you either need to copy it to your local node, or you need to use a network file system, such as NFS or similar.