How to access /proc/ file (procfs) via SSHFS

fcdt

Using a computer with Ubuntu 16.04 (no update suggestions please) I mounted /proc/ at my Raspberry Pi 3B + (linux kernel version 4.19.88) via SSHFS:

sshfs [email protected]:/proc ~/procAtPi
ls -la ~/procAtPi

Here ls shows me all files in the Pi's /proc without any problems, just as I had connected directly via ssh. But when I try to read the files with cat, nothing is displayed here. The file content is only output to me when I connect directly via

user@remote:~$ ssh [email protected]
[email protected]:~$ cat /proc/stat

How can I read out a file from procfs that I access via SSHFS?

Some more observations I made:

  • Using sudo cat ~/procAtPi/stat leads to Access denied (So root seems to have fewer access rights than the normal user?) but the files owner is root:

    user@remote:~$ ls -lai ~/procAtPi/stat
          16 -r--r--r--   1 root             root                0 Dez 24 00:00 stat
    
  • The displayed owner differs depending on the access:

    user@remote:~$ ls -lai ~/procAtPi/
         ...
         171 dr-xr-xr-x   1 user             user                0 Jan 20 09:18 11045
         ...
    [email protected]:~$ ls -lai /proc/
         ...
    2035700 dr-xr-xr-x   8 pi               pi                  0 Jan 20 09:18 11045
         ...
    
  • Remote access to files in the Pi's sysfs (/sys/) seems to work fine.

A current workaround is to run a server on the Pi that reads the data from /proc/stat and makes it available via TCP. To do so, however, I have to start the server manually every time (I don't want an autostart because I don't need it all the time). I need access to proc/stat for a htop-like program that is supposed to monitor my Pi cluster.

Uncle Billy

ls shows me all files in the Pi's /proc without any problems, just as I had connected directly via ssh. But when I try to read the files with cat, nothing is displayed here.

As a workaround, use the -o direct_io option of sshfs:

# sshfs localhost:/proc /mnt/tmp
root@localhost's password:
# cat /mnt/tmp/self/stat
<nothing!>
# umount /mnt/tmp

# sshfs -o direct_io localhost:/proc /mnt/tmp
root@localhost's password:
# cat /mnt/tmp/self/stat
8242 (sftp-server) R 8236 8242 8242 0 -1 4194560 335 0 0 0 0 0 0 0 20 0 1 0 1846105 2506752 441 18446744073709551615 94732486082560 94732486157085 140730261312560 0 0 0 0 0 0 0 0 0 17 3 0 0 0 0 0 94732486190800 94732486194248 94732486483968 140730261319328 140730261319357 140730261319357 140730261319643 0

See here for a description of what that option is doing.

The problem with those files under /proc is that they appear as regular files of size = 0, yet they're not empty and contain data when read.

Notice that this problem is NOT caused by the SFTP protocol, and is not specific to sshfs.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I specify the key file for sshfs?

From Dev

How to attach file via "Bugzilla XMLRPC access module"

From Dev

How to access the Camera via Bluetooth?

From Dev

How to prevent access via reflection?

From Dev

How to access iOS simulator file system via SSH?

From Dev

How to access a database file on a remote machine via UCanAccess?

From Dev

sshfs, linux - how to mount with read-only access

From Dev

How to specify key in SSHFS?

From Dev

How to access apache log file via php (Not parsing Log file)

From Dev

How to specify key in SSHFS?

From Dev

How to mount remote SSHFS via intermediate machine? Tunneling?

From Dev

How to control thinkpad_acpi via procfs, RHEL 6.4

From Dev

read_proc_t and file_operations in procfs

From Dev

Running sshfs as user via autofs

From Dev

Connect to remote socket via sshfs

From Dev

sshfs LocalForward without config file

From Dev

How can you execute files mounted via sshfs?

From Dev

Why is sshfs not shown in /proc/filesystems?

From Dev

Mount with sshfs and write file permissions

From Dev

How frequently is the proc file system updated on Linux?

From Dev

How to automount sshfs?

From Dev

sshfs - No such file or directory

From Dev

How to enable access to the kernel config file through /proc/config.gz?

From Dev

How to calll a stored proc via nHibernate which returns nothing

From Dev

How to use sshfs and ssh from a linux virtual machine to access the linux host

From Dev

open remote (ssh) file locally via comand line (without installing sshfs)

From Dev

access sshfs directory with gui

From Dev

sshfs 'no such file' error

From Dev

How to access properties via RPC

Related Related

HotTag

Archive