首页
/ Posh-SSH 技术文档

Posh-SSH 技术文档

2024-12-28 21:09:47作者:傅爽业Veleda

1. 安装指南

要安装 Posh-SSH 模块,请在 PowerShell 中运行以下命令:

Install-Module -Name Posh-SSH

确保您的 PowerShell 版本为 5.1 或 PowerShell 7.x。在 Windows Server 上,版本 1709 或更旧版本需要 .Net Framework 4.8 或更高版本才能正确加载模块。

2. 使用说明

Posh-SSH 是一个 Windows PowerShell 模块,利用定制版的 SSH.NET 库提供基本的 SSH 功能。该模块旨在方便从 Windows 主机自动化对一个或多个 SSH 启用的 Linux 服务器执行操作。从版本 3.x 开始,该模块可以在 Linux 和 Mac OS 上使用 .Net Standard。

3. 项目 API 使用文档

支持的功能

  • 自动化 SSH、SFTP 和 SCP 操作。
  • 支持 SOCKS4、SOCKS5 和 HTTP 代理。
  • 远程、动态和本地端口转发。
  • 支持多种加密方法、密钥交换方法、私钥格式和主机密钥算法。

加密方法和密钥交换

以下是 Posh-SSH 支持的加密方法和密钥交换方法:

# 加密方法
$aesMethods = @('aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc', '3des-cbc', 'blowfish-cbc', 'twofish-cbc', 'twofish192-cbc', 'twofish128-cbc', 'twofish256-cbc', 'arcfour', 'arcfour128', 'arcfour256', 'cast128-cbc')

# 密钥交换方法
$keyExchangeMethods = @('curve25519-sha256', 'curve25519-sha256@libssh.org', 'ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group16-sha512', 'diffie-hellman-group14-sha256', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1')

私钥格式

Posh-SSH 支持以下私钥格式:

  • RSA (OpenSSL PEM 和 ssh.com 格式)
  • DSA (OpenSSL PEM 和 ssh.com 格式)
  • ECDSA (OpenSSL PEM 格式)
  • ED25519 和 RSA (OpenSSH key 格式)

主机密钥算法

支持的主机密钥算法包括:

$hostKeyAlgorithms = @('ssh-ed25519', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa', 'ssh-dss')

MAC 算法

支持的 MAC 算法包括:

$macAlgorithms = @('hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha2-512-96', 'hmac-sha2-256-96', 'hmac-sha1', 'hmac-sha1-96', 'hmac-md5', 'hmac-md5-96', 'hmac-sha2-256-etm@openssh.com', 'hmac-sha2-512-etm@openssh.com', 'hmac-sha1-etm@openssh.com', 'hmac-sha1-96-etm@openssh.com', 'hmac-md5-etm@openssh.com', 'hmac-md5-96-etm@openssh.com')

4. 项目安装方式

除了使用 PowerShell 的 Install-Module 命令安装外,您还可以通过以下方式安装 Posh-SSH:

  • 手动下载模块的压缩包,解压后放置到 PowerShell 的模块目录中。
  • 使用 PowerShellGet 模块的 Update-Module 命令来更新已安装的模块。

请确保遵循相应的安装指南以确保模块的正确安装和使用。

登录后查看全文
热门项目推荐