Troubleshooting sshfs mount failures
Write code to run on Linux, but familiar IDE (such as VS code) on your own computer, you can use sshfs to mount the directory on linux locally, and then just open it with VScode, you can use the following command:
sshfs -odebug,sshfs_debug,loglevel=debug -o rw,allow_other,uid=1190,gid=1190,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,IdentityFile=/Users/hailiang8/.privateKey [email protected]:/data1/workspace/mount/ffmpeg /Users/harlanc/workspace_ffmpeg
But today I encountered a problem, in other CentOS machine no problem, but to 192.168.23.2 this machine can not connect, reported the following error:
SSHFS version 2.5
FUSE library version: 2.9.9
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
executing <ssh> <-x> <-a> <-oClearAllForwardings=yes> <-ologlevel=debug> <-oServerAliveInterval=15> <-oServerAliveCountMax=3> <-oIdentityFile=/Users/ harlanc/.privateKey> <-2> <[email protected]> <-s> <sftp>
debug1: Reading configuration data /Users/harlanc/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 192.168.23.2 [192.168.23.2] port 22.
debug1: Connection established.
debug1: identity file /Users/harlanc/.privateKey type -1
debug1: identity file /Users/harlanc/.privateKey-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.8
kex_exchange_identification: read: Connection reset by peer
Connection reset by 192.168.23.2 port 22
remote host has disconnected
The server is actively disconnecting, check the server's ssh service:
[root@harlanc]# netstat -nltp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1085/sshd
tcp6 0 0 :::22 :::* LISTEN 1085/sshd
Looking at the specifics of the ssh process:
[root@ harlanc]# ps -ef | grep 1085
root 1085 1 0 15:39 ? 00:00:00 /usr/local/sbin/sshd -D
[root@ harlanc]# rpm -qf /usr/local/sbin/sshd
***openssh-6.7.x86_64 //here **** is the name of our company
It turns out that we were using our company's own ssh service.
And in the CentOS machine can be connected to the use of openssh this open source ssh service, to replace our service is not very realistic, you can change the openssh service to a port to start up:
vim /etc/ssh/sshd_config
locate
Port 22
replace with
Port 23
Get openssh up and running:
[root@ harlanc]# systemctl start sshd
Now both services are up:
[root@ harlanc]# netstat -nltp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1085/sshd
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 316299/sshd
tcp6 0 0 :::22 :::* LISTEN 1085/sshd
tcp6 0 0 :::23 :::* LISTEN 316299/sshd
Specify the port when mounting with sshfs:
sshfs -p 23 -odebug,sshfs_debug,loglevel=debug -o rw,allow_other,uid=1190,gid=1190,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,IdentityFile=/Users/hailiang8/.privateKey [email protected]:/data1/workspace/mount/ffmpeg /Users/harlanc/workspace_ffmpeg
It finally mounted at last.
harlanc@APB ~ % df -h
Filesystem Size Used Avail Capacity iused ifree %iused
[email protected]:/data1/workspace/mount/ffmpeg 295Gi 237Gi 58Gi 81% 1.4M 18M 7% /Users/harlanc/workspace_ffmpeg