3个版本
0.0.4 | 2023年12月20日 |
---|---|
0.0.3 | 2023年12月16日 |
0.0.2 | 2023年12月15日 |
#1469 in 网络编程
35KB
745 代码行
Blaze SSH
描述
Blaze SSH是一个可配置的CLI工具,帮助您在不离开终端的情况下SSH连接到亚马逊aws ec2实例。它是用Rust编写的,并使用官方的Rust AWS SDK。配置是通过默认的.toml
文件("~/.config/blaze/config.toml"
)完成的。
动机
我已经使用aws-ssh有一段时间了。这是一个很棒的工具,但是所有的依赖项,如fzf、jq、aws-cli等,使得将应用程序打包成易于安装的格式变得很困难。此外,作为一个喜欢尝试新shell的人,不得不切换回zsh才能使用aws-ssh,这很不方便。
这个工具通过将依赖项保持在最低限度并使用Rust构建单个可执行二进制文件来解决此问题。aws-ssh的一些便利功能目前尚未提供,但很快将添加,包括aws-ecs支持等一些附加功能。
安装
目前,安装blaze的唯一方法是通过cargo
$ cargo install blaze-ssh
安装后,请确保在~/.config/blaze/config.toml
创建一个配置文件。有关详细信息,请参阅配置。您可以使用configure
命令生成默认配置文件。
$ blssh configure
用法
Usage: blssh [OPTIONS] <COMMAND>
Commands:
connect connect to an ec2 instances
list list filtered ec2 instances
configure generate default config (~/.config/blssh/config.toml)
help Print this message or the help of the given subcommand(s)
Options:
--no-cache disable using cached ec2 instances list
-c, --config <CONFIG> config
-h, --help Print help
# Connection Opts
connect to an ec2 instances
Usage: blssh connect [OPTIONS] [SEARCH]
Arguments:
[SEARCH] Search String to filter instances by
Options:
-u, --user <USER> ssh username
-p, --port <PORT> ssh port
-k, --key <KEY> ssh private key
-a, --address-type <ADDRESS_TYPE>
-j, --jumphost <JUMPHOST> jumphost
-h, --help Print help
配置
目前,blaze-ssh期望在~/.config/blaze/config.toml
找到配置文件。请确保创建此文件。
[config]
private-key = "~/.ssh/id_rsa.pem"
default-user = "ec2-user"
jumphost = ""
port = 22
address-type = "private"
示例
列出实例
# Lists all instances that contain the term "staging" in their "Name" tag
$ blssh list staging
连接到实例
# Interactively select an instance to connect to from a list of instances that contain the term "production-1" in their "Name" tag
$ blssh connect production-1
# Connecting with a non default (configured in ~/.config/blaze/config.toml) private key
$ blssh connect production-1 --key ~/.ssh/production.pem
# Connecting with a non default (configured in ~/.config/blaze/config.toml) user
$ blssh connect production-1 --user ubuntu
# Connecting with a non default (configured in ~/.config/blaze/config.toml) port
$ blssh connect production-1 --port 2222
# Connecting with a non default jumphost host
$ blssh connect production-1 --jumphost "[email protected]"
# Connecting with a non default (configured in ~/.config/blaze/config.toml) address type
# Options are "public" & "private"
$ blssh connect production-1 --address-type public
# Connect using a custom config
$ blssh --config ~/custom-config.toml connect production-1
# Disable use of cached instance information (stored in /tmp/blaze_ssh_cache.json)
$ blssh --no-cache connect production-1
已知问题
- 在使用j/k在连接UI中导航时,列表滚动不工作。
- 没有配置文件的行为尚未测试。
路线图
- 修复已知问题
- 为分发打包应用程序
- 如果只找到一个实例,则直接连接到它而无需显示连接UI PR #1
依赖项
~79MB
~1M SLoC