Skip to content

Commit

Permalink
Feature/1.1.0 (#14)
Browse files Browse the repository at this point in the history
* refactor & use go module
* 调整菜单编排方式
* 增加分组折叠功能
* 增加别名
* 支持快速登录
* 优化帮助菜单输出
* 增加版本检测功能
* 一键安装脚本
* 增加日志保存功能
* 记录log
* 删除功能支持ctrl d退出
* 增加文件上传/下载功能
  • Loading branch information
islenbo authored Jul 6, 2019
1 parent 8524ba4 commit 2ca609f
Show file tree
Hide file tree
Showing 34 changed files with 1,883 additions and 835 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
servers.json
config.json
releases/
.idea/
.idea
main
test.go
app.log
vendor
91 changes: 18 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,92 +4,37 @@

![演示](https://raw.githubusercontent.com/islenbo/autossh/b3e18c35ebced882ace59be7843d9a58d1ac74d7/doc/images/ezgif-1-a4ddae192f.gif)

## 版本说明
这是一个全新的autossh,无法兼容v0.2及以下版本,升级前请做好备份!新版配置文件由原来的`servers.json`改为`config.json`
升级时可将旧配置文件的列表插入到新配置文件的`servers`节点下

注:旧版servers中method=pem需要更新为method=key

## 功能说明
- 支持分组
- 支持显示/隐藏主机详情(show_detail)
- 支持options(目前仅支持ServerAliveInterval)
- 允许配置文件中server默认值为空
- 允许指定配置文件目径
- 修复终端窗口大小改变时无法自适应的bug
- 核心代码重构,使用go.mod管理依赖
- 新增分组折叠功能
- 新增自动更新检测功能
- 新增一键安装脚本
- 新增会话日志保存功能
- 删除功能支持ctrl+d退出
- 优化帮助菜单显示
- 修复若干Bug

## 下载
[https://github.com/islenbo/autossh/releases](https://github.com/islenbo/autossh/releases)

## 安装
- 下载编译好的二进制包autossh,放在指目录下,如`~/autossh``/usr/loca/autossh`
- 同级目录下新建`config.json`文件,参考`config.example.json`
- 将安装目录加入环境变量中,或指定别名`alias autossh=your autossh path/autossh`

## config.json
```json
{
"show_detail": true, // 显示主机详情
"options": { // 全局配置
"ServerAliveInterval": 30 // 发送心跳包时间,同 ssh -o ServerAliveInterval=30
},
"servers": [
{
"name": "vagrant", // 显示名称
"ip": "192.168.33.10", // 主机地址
"port": 22, // 端口号,可省略,默认为22
"user": "root", // 用户名
"password": "vagrant", // 密码,使用无密码的key登录时可省略
"method": "password", // 认证方式,可省略,默认值为password,可选项有password、key
"key": "", // 密钥路径,method=key时有效,可省略,默认为~/.ssh/id_rsa
"options": { // 自定义配置,会覆盖配置中相同的值
"ServerAliveInterval": 20
}
},
{
"name": "vagrant-key",
"ip": "192.168.33.10",
"user": "root",
"method": "key"
}
],
"groups": [
{
"group_name": "your group name",
"prefix": "a",
"servers": [
{
"name": "example1",
"ip": "192.168.33.10",
"user": "root",
"password": "root"
},
{
"name": "example2",
"ip": "192.168.33.10",
"user": "root",
"password": "root"
}
]
},
{
"group_name": "group2",
"prefix": "b",
"servers": [
]
}
]
}
- Mac/Linux用户直接下载安装包,运行install脚本即可。
- Windows用户可手动编译,参考编译章节。

```
## config.json字段说明
- TODO 字段说明

## Q&A
- Q: Downloads中为什么没有Windows的包?
- A: Windows下有很多ssh工具,autossh主要是面向Mac/Linux群体。

## 编译
export GO111MODULE="on"
export GOFLAGS=" -mod=vendor"
go build main.go

## 依赖包
- golang.org/x/crypto/ssh
## 依赖
- 查阅 go.mod

## 注意
v0.X版本配置文件无法与v1.X版本兼容,请勿使用!
6 changes: 4 additions & 2 deletions build.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

PROJECT="autossh"
VERSION="v1.0.0"
VERSION="v1.1.0"
BUILD=`date +%FT%T%z`

function build() {
Expand All @@ -12,8 +12,10 @@ function build() {

echo "build ${package} ..."
mkdir -p "./releases/${package}"
CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -o "./releases/${package}/autossh" -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}" main.go
CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -o "./releases/${package}/autossh" -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}" src/main/main.go
cp ./config.example.json "./releases/${package}/config.json"
chmod +x ./install
cp ./install "./releases/${package}/install"
cd ./releases/
zip -r "./${package}.zip" "./${package}"
echo "clean ${package}"
Expand Down
52 changes: 24 additions & 28 deletions config.example.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{
"show_detail": true, // 显示主机详情
"options": { // 全局配置
"ServerAliveInterval": 30 // 发送心跳包时间,同 ssh -o ServerAliveInterval=30
"show_detail": true,
"options": {
"ServerAliveInterval": 30
},
"servers": [
{
"name": "vagrant", // 显示名称
"ip": "192.168.33.10", // 主机地址
"port": 22, // 端口号,可省略,默认为22
"user": "root", // 用户名
"password": "vagrant", // 密码,使用无密码的key登录时可省略
"method": "password", // 认证方式,可省略,默认值为password,可选项有password、key
"key": "", // 密钥路径,method=key时有效,可省略,默认为~/.ssh/id_rsa
"options": { // 自定义配置,会覆盖配置中相同的值
"name": "example-password",
"ip": "example-password",
"port": 22,
"user": "example-password",
"password": "example-password",
"method": "example-password",
"key": "",
"options": {
"ServerAliveInterval": 20
}
},
"alias": "example"
},
{
"name": "vagrant-key",
"ip": "192.168.33.10",
"user": "root",
"name": "example-key",
"ip": "example-key",
"user": "example-key",
"method": "key"
}
],
Expand All @@ -30,23 +31,18 @@
"servers": [
{
"name": "example1",
"ip": "192.168.33.10",
"user": "root",
"password": "root"
"ip": "example1",
"user": "example1",
"password": "example1"
},
{
"name": "example2",
"ip": "192.168.33.10",
"user": "root",
"password": "root"
"ip": "example2",
"user": "example2",
"password": "example2"
}
]
},
{
"group_name": "group2",
"prefix": "b",
"servers": [
]
],
"collapse": false
}
]
}
Loading

0 comments on commit 2ca609f

Please sign in to comment.