ssh-config-loader
v1.1.2
Published
A library to read SSH config and convert to electerm bookmark format
Maintainers
Readme
ssh-config-loader
A JavaScript/TypeScript library to parse SSH config (~/.ssh/config) and convert to electerm-bookmark format.
Features
- Parse SSH config files with full support for all common SSH options
- Convert SSH config to electerm-bookmark format
- Support custom config paths
- TypeScript support
- Both ESM and CJS builds
Installation
npm install ssh-config-loaderUsage
import { loadSshConfig, loadAndConvert, sshConfigHostToBookmark } from 'ssh-config-loader'
// Load and convert SSH config to electerm bookmarks
const bookmarks = loadAndConvert()
// Specify custom config path
const bookmarks = loadAndConvert({
configPath: '/path/to/config',
defaultUsername: 'myuser',
defaultPort: 22
})
// Manual parsing and conversion
const config = loadSshConfig({ configPath: '/path/to/config' })
const bookmark = sshConfigHostToBookmark(config.hosts[0])API
loadAndConvert(options?)
Load SSH config and convert to electerm bookmarks.
Options:
configPath?: string- Custom SSH config path (default: ~/.ssh/config)includeDefaultPaths?: boolean- Include default paths (default: true)defaultUsername?: string- Default username if not specified in configdefaultPort?: number- Default port (default: 22)
Returns: ElectermBookmarkSsh[]
loadSshConfig(options?)
Load and parse SSH config file(s).
Options:
configPath?: string- Custom SSH config pathincludeDefaultPaths?: boolean- Include default paths (default: true)
Returns: SshConfig
sshConfigHostToBookmark(host, options?)
Convert a single SSH config host to electerm bookmark.
Parameters:
host: SshConfigHost- SSH config host entryoptions?: ToBookmarkOptions- Conversion options
Returns: ElectermBookmarkSsh
SSH Config Options Supported
- Host, HostName, Port, User
- IdentityFile (multiple keys supported)
- ProxyJump (SSH hopping)
- ProxyCommand
- ForwardAgent
- ServerAliveInterval, ServerAliveCountMax
- Compression
- ConnectionAttempts, ConnectTimeout
- TCPKeepAlive
- ControlMaster, ControlPath, ControlPersist
- And more...
NPM Scripts
npm run build- Build ESM and CJSnpm run test- Run testsnpm run lint- Lint codenpm run lint:fix- Fix lint errorsnpm run format- Format code
License
MIT
