Skip to content

Instantly share code, notes, and snippets.

@GokulNC
Last active September 8, 2019 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GokulNC/1fc2f411cb5ef42b1952cd652edb7d75 to your computer and use it in GitHub Desktop.
Save GokulNC/1fc2f411cb5ef42b1952cd652edb7d75 to your computer and use it in GitHub Desktop.
Mounts remote SSH machine's file system on local machine using SSH-FS
@echo off
:: OpenSSH Private Key File
set KEY_PATH=C:\\Users\\GokulNC\\Desktop\\Keys\\GCP_VM\\id_rsa
set USERNAME=GokulNC_GCP
set REMOTE_DIR=/
set /p IP=Enter the IP:
set /p DriveLetter=Enter the mount drive letter:
set CYGFUSE=WinFsp
set PATH=C:\Program Files (x86)\SSHFS-Win\bin;%PATH%
sshfs.exe -ofstypename=SSHFS -o idmap=user -o umask=000 -o volname=%IP% -o Compression=no -o reconnect,ServerAliveInterval=120 -o IdentityFile=%KEY_PATH% %USERNAME%@%IP%:%REMOTE_DIR% %DriveLetter%:
:: Wait a few secs for it to become stable
timeout 3 >NUL
echo.
echo.
IF EXIST %DriveLetter%:\ (
echo Connected to %USERNAME%@%IP% successfully and mounted %REMOTE_DIR% at %DriveLetter%:\
echo.
echo Minimize this window and continue browsing your remote host's FS.
echo To terminate the connection, close this window.
) ELSE (
echo Connection FAILED! Close this window.
)
pause >NUL
pause >NUL
echo Connection terminated. Close this window.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment