LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Monitoring SSHFS connections (https://www.linuxquestions.org/questions/linux-security-4/monitoring-sshfs-connections-4175644397/)

upnort 12-16-2018 01:57 PM

Monitoring SSHFS connections
 
How does one monitor SSHFS connections?

I hope I am overlooking something obvious. I am not looking for information about malicious hacking. Just normal monitoring.

When connecting directly through SSH, the shell history reveals the user's commands. Not so with SSHFS. Files can be changed through SSHFS and the shell history is never touched.

The /var/log/secure (audit.log) shows who connected but not any activity.

Thanks. :)

scasey 12-16-2018 02:04 PM

Since sshfs provides a local mount of a remote file system, wouldn't any activity be reflected in the local history/logs?
I woudn't expect the remote system to know anything about activity, although of course a change (add/remove/edit) of a file on the local system would be visible (but not logged) on the remote system.

upnort 12-16-2018 03:36 PM

Quote:

wouldn't any activity be reflected in the local history/logs
Possibly, but access to that history or logs is unlikely if personal systems are used for the access. That in itself is a different security topic for another day. :)

At the moment, looks like I might have to learn about the built-in kernel auditing.

berndbausch 12-16-2018 03:48 PM

Quote:

Originally Posted by upnort (Post 5937863)

When connecting directly through SSH, the shell history reveals the user's commands. Not so with SSHFS. Files can be changed through SSHFS and the shell history is never touched.

Let me point out that the user has full control of the Bash history and can switch it off. Or use a shell that doesn’t have a history mechanism.

I think you want an intrusion detection system. Alternatively, you could audit exec and open system calls.

upnort 12-16-2018 03:55 PM

Quote:

Let me point out that the user has full control of the Bash history and can switch it off. Or use a shell that doesn’t have a history mechanism.
Yes, I know. Thankfully that is not an issue though. :)

Quote:

I think you want an intrusion detection system.
Possibly, but probably not. I already know who is logged in, when, and from what IP address. I just can't tell what was changed when SSHFS is used rather than direct SSH login. And yes, sometimes "who" logged in through SSHFS is me. :)

Quote:

Alternatively, you could audit exec and open system calls.
Yes, I mentioned that in my previous post. :)

michaelk 12-16-2018 05:36 PM

sshfs is the fuse file system for sftp which is a subsystem of ssh. You need to enable sftp log level in your server's sshd_config file. I believe the logs will be in the system log file which depends on the distribution.

Assuming your not using a chroot user try this:

Subsystem sftp /usr/libexec/openssh/sftp-server -l VERBOSE

I don't know if anything is logged on the client.

Habitual 12-17-2018 12:45 PM

check syslog

ondoho 12-18-2018 01:42 AM

Quote:

Originally Posted by michaelk (Post 5937932)
sshfs is the fuse file system for sftp which is a subsystem of ssh. You need to enable sftp log level in your server's sshd_config file. I believe the logs will be in the system log file which depends on the distribution.

this.
also fuse can probably be tweaked somehow to output informational messages.
lastly sshfs has some options of its own too.

another of these questions that wouldn't have been asked if OP had done their research, or at the very least RTFM (read the fruitful manual).

Turbocapitalist 12-18-2018 02:51 AM

Quote:

Originally Posted by michaelk (Post 5937932)
Assuming your not using a chroot user try this:

Subsystem sftp /usr/libexec/openssh/sftp-server -l VERBOSE

If you do a lot of logging, you can make a separate log file by giving the SFTP activity a different log facility, e.g. LOCAL2, instead of the default of AUTH.

Code:

Subsystem  sftp    /usr/libexec/openssh/sftp-server -f LOCAL4 -l VERBOSE
Then adjust your log server and log rotation to deal with the SFTP logs separately.

upnort 01-22-2019 01:16 PM

Funny how priority lists get changed. I finally was able to get back to this task.

Thanks much for the friendly nudging about SSHFS being a FUSE subsystem and being related to SFTP. For the moment I am using INFO logging details on a test system. I decided to dump the output to the SSH authentication log. Working fine, although I had to tweak rsyslog.conf. Oddly, authpriv.* was defined but not auth.*, which I added.

In summary,

* Edit /etc/ssh/sshd_config:

Code:

Subsystem        sftp        /usr/libexec/openssh/sftp-server -l info -f auth
* Edit /etc/rsyslog.conf:

Code:

authpriv.*                                    /var/log/secure
auth.*                                        /var/log/secure

I'll tag this topic as solved.

Quote:

another of these questions that wouldn't have been asked if OP had done their research, or at the very least RTFM (read the fruitful manual).
Pompous and not constructive. Sometimes people need some friendly nudging.


All times are GMT -5. The time now is 03:21 PM.