npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bobfrankston/mountsmb

v1.1.36

Published

Cross-platform SMB mounting solution for Windows, WSL, and Linux

Readme

mountsmb - Cross-Platform SMB Mounting

A comprehensive SMB mounting solution that provides seamless access to remote filesystems across Windows, WSL, and Linux environments.

Quick Start

# Install globally from npm
npm install -g @bobfrankston/mountsmb

# Mount a remote host's root filesystem
mountsmb beta1

# Mount a specific path
mountsmb pi3a /var/www

# From source directory
node index.js beta1

Features

  • Automatic hostname resolution from SSH config files
  • Platform-aware dual mounting (WSL creates both native and Windows mounts)
  • Automatic Samba installation and configuration on remote hosts
  • SSH key authentication for secure connections
  • Persistent connections that survive reboots
  • Cross-platform API for programmatic use

Installation

The script automatically installs required dependencies:

  • WSL/Linux: cifs-utils for native SMB mounting
  • Remote hosts: samba server with automatic configuration

Command Line Usage

Basic Commands

# Mount commands
mountsmb <hostname>              # Mount root filesystem
mountsmb <hostname> <path>       # Mount specific path
mountsmb beta1 --install-samba   # Force Samba reinstallation
mountsmb beta1 --verbose         # Enable verbose logging
mountsmb beta1 --debug           # Enable debug messages

# Management commands
mountsmb list                    # Show active mounts
mountsmb unmount beta1           # Unmount specific host
mountsmb cleanup                 # Remove dead mounts
mountsmb show-mappings           # Display hostname mappings
mountsmb sync-config             # Sync Windows/WSL configs

Windows Wrapper

Use the batch wrapper for Windows:

mountsmb beta1
mountsmb unmount beta1

Location: Y:\x\bin\mountsmb.cmd

Configuration

SSH Config Setup

Ensure your SSH config includes host definitions with users:

# Windows: C:\Users\{USER}\.ssh\config
# WSL: ~/.ssh\config

Host beta1
    HostName beta1.frankston.com
    User root  # Required

Host pi3a
    HostName pi3a.aaz.lt
    User pi    # Required

REQUIRED: A User MUST be specified in SSH config for each host.

JSON Override (Optional)

For hosts not in SSH config:

# ~/.mountsmb/hostnames.json
{
  "dev": "development.example.com",
  "prod": "production.example.com"
}

Access Paths

After mounting, access your files through platform-appropriate paths:

WSL Environment

# Native WSL mount (recommended)
cd /mnt/smb/beta1
ls ~/mounts/beta1          # Convenience symlink

# Cross-platform
ls /mnt/c/drives/smb/beta1  # Windows junction from WSL

Windows Environment

REM Native Windows access
cd C:\drives\smb\beta1
dir \\beta1.frankston.com\beta1  REM Direct UNC access

Directory Structure

Platform-specific mounts:
├── WSL Native:     /mnt/smb/{hostname}
├── WSL Symlink:    ~/mounts/{hostname} → /mnt/smb/{hostname}
├── Windows:        C:\drives\smb\{hostname} → \\{hostname}\{hostname}
└── UNC Direct:     \\{hostname}.domain.com\{hostname}

Programming API

TypeScript/JavaScript Import

import { 
  mountSMBHost, 
  unmountSMBHost,
  getActiveMounts,
  getHostnameMappings,
  getConnectionInfo,
  cleanupDeadMounts,
  syncHostnameConfigs
} from '@bobfrankston/mountsmb';

Core Functions

Mount Operations

// Mount a host's root filesystem
await mountSMBHost('beta1');

// Mount specific path with options
await mountSMBHost('pi3a', { remotePath: '/var/www', installSamba: true });

// Mount with explicit verbose/debug control
await mountSMBHost('beta1', { verbose: false, debug: false }); // Quiet mode

// Unmount
await unmountSMBHost('beta1');

Information Queries

// Get all active mounts
const mounts = getActiveMounts();

// Get hostname mappings from SSH config
const mappings = getHostnameMappings();

// Get resolved connection info
const conn = getConnectionInfo('beta1');

Maintenance Operations

// Clean up dead mounts
const cleaned = cleanupDeadMounts();

// Sync hostname configs between Windows and WSL
const result = syncHostnameConfigs();

Interface Types

interface ConnectionInfo {
  user: string;           // SSH username  
  host: string;          // Full hostname for connections
  mountName: string;     // Short name for mount points
  remotePath: string;    // Remote path being mounted
}

interface MountOptions {
  installSamba?: boolean;  // Force Samba installation
  verbose?: boolean;        // Enable verbose logging
  debug?: boolean;          // Enable debug output
  remotePath?: string;      // Path to mount (default: "/")
}

Troubleshooting

Common Issues

"Command failed: ssh user@host"

  • Verify SSH key authentication works: ssh beta1
  • Check hostname resolution: nslookup beta1.frankston.com

"SMB share is not accessible"

  • Force Samba reinstallation: mountsmb beta1 --install-samba
  • Check Samba status: ssh beta1 "systemctl status smbd"

"I/O error accessing /mnt/c/drives/smb/"

  • Use WSL native path instead: /mnt/smb/beta1 or ~/mounts/beta1
  • This is a known WSL limitation with Windows SMB junctions

"Permission denied mounting"

  • Install cifs-utils: sudo apt install cifs-utils
  • Check sudo privileges for mount commands

Debug Commands

# Show detailed mounting information
mountsmb beta1 --debug

# List all active mounts with status
mountsmb list

# Test hostname resolution
mountsmb show-mappings

# Clean up broken mounts
mountsmb cleanup

Manual Mount Commands

If the script fails, you can mount manually:

# WSL/Linux manual mount
sudo mkdir -p /mnt/smb/beta1
sudo mount -t cifs //beta1.frankston.com/beta1 /mnt/smb/beta1 \
    -o user=root,password=smb_beta1,vers=3.0

# Windows manual mount  
net use \\beta1.frankston.com\beta1 smb_beta1 /user:root
mklink /D C:\drives\smb\beta1 \\beta1.frankston.com\beta1

Security Notes

  • Uses SSH key authentication for initial setup
  • SMB passwords are auto-generated per host: smb_{hostname}
  • Requires SMB3 with encryption for secure transport
  • Samba shares restricted to specific users (no guest access)

Examples

Basic Usage

# Mount beta1's root filesystem
mountsmb beta1

# Access files
ls ~/mounts/beta1/etc/
vim ~/mounts/beta1/root/config.txt

API Usage

import { mountSMBHost, getActiveMounts } from '@bobfrankston/mountsmb';

// Mount multiple hosts
await mountSMBHost('beta1');
await mountSMBHost('pi3a', { remotePath: '/var/www' });

// Check status
const mounts = getActiveMounts();
console.log(`Active mounts: ${mounts.length}`);

Cross-Platform Development

// Works in both Windows and WSL
function getDataPath(hostname: string): string {
  if (process.platform === 'win32') {
    return `C:\\drives\\smb\\${hostname}\\data`;
  } else {
    return `/mnt/smb/${hostname}/data`;
  }
}

await mountSMBHost('beta1');
const configPath = getDataPath('beta1');
const config = readFileSync(join(configPath, 'app.json'), 'utf8');

Additional Tools

For advanced usage and troubleshooting, see companion utilities in /mnt/c/Users/Bob/OneDrive/xfer/bin/linuxbin/:

  • setupkeys.ts: Automated SSH key setup and management
  • assuressh: Verify SSH connectivity to hosts
  • check-mount: Validate mount point status and accessibility
  • mount-status: Detailed mount information and diagnostics

Support