gssh-agent 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '**'
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Go
19
+ uses: actions/setup-go@v5
20
+ with:
21
+ go-version: '1.21'
22
+
23
+ - name: Build
24
+ run: go build ./...
25
+
26
+ - name: Test
27
+ run: go test ./...
@@ -0,0 +1,104 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ # npm 发布
10
+ publish-npm:
11
+ if: "contains(github.event.head_commit.message, 'publish')"
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ id-token: write
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Go
20
+ uses: actions/setup-go@v5
21
+ with:
22
+ go-version: '1.21'
23
+
24
+ - name: Get version
25
+ id: version
26
+ run: |
27
+ VERSION=$(echo "${{ github.event.head_commit.message }}" | sed -n 's/.*publish[: ]*\(.*\)/\1/p')
28
+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
29
+ echo "Publishing version: $VERSION"
30
+
31
+ - name: Build
32
+ run: |
33
+ go build -ldflags="-s -w" -o bin/gssh ./cmd/gssh
34
+
35
+ - name: Update package.json version
36
+ run: |
37
+ VERSION="${{ steps.version.outputs.VERSION }}"
38
+ npm version $VERSION --no-git-tag-version
39
+
40
+ - name: Build npm package
41
+ run: npm pack
42
+
43
+ - name: Setup Node
44
+ uses: actions/setup-node@v4
45
+ with:
46
+ node-version: '20'
47
+
48
+ - name: Configure npm
49
+ run: |
50
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
51
+ cat .npmrc
52
+
53
+ - name: Publish to npm
54
+ run: npm publish --access public
55
+
56
+ # GitHub Releases 发布
57
+ publish-github:
58
+ if: "startsWith(github.ref, 'refs/tags/v')"
59
+ runs-on: ubuntu-latest
60
+ permissions:
61
+ contents: write
62
+
63
+ strategy:
64
+ matrix:
65
+ include:
66
+ - goos: linux
67
+ goarch: amd64
68
+ - goos: linux
69
+ goarch: arm64
70
+ - goos: darwin
71
+ goarch: amd64
72
+ - goos: darwin
73
+ goarch: arm64
74
+ - goos: windows
75
+ goarch: amd64
76
+
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+
80
+ - name: Set up Go
81
+ uses: actions/setup-go@v5
82
+ with:
83
+ go-version: '1.21'
84
+
85
+ - name: Build
86
+ env:
87
+ GOOS: ${{ matrix.goos }}
88
+ GOARCH: ${{ matrix.goarch }}
89
+ run: |
90
+ EXT=""
91
+ if [ "$GOOS" = "windows" ]; then
92
+ EXT=".exe"
93
+ fi
94
+ FILENAME="gssh-${GOOS}-${GOARCH}${EXT}"
95
+ go build -ldflags="-s -w" -o "$FILENAME" ./cmd/gssh
96
+ echo "$FILENAME" >> artifacts.txt
97
+
98
+ - name: Upload Release Asset
99
+ uses: softprops/action-gh-release@v2
100
+ with:
101
+ tag_name: ${{ github.ref }}
102
+ files: ${{ matrix.goos }}-${{ matrix.goarch }}*
103
+ env:
104
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/README.md CHANGED
@@ -14,22 +14,13 @@ gssh 是一个供 Agent 使用的 SSH Session 管理工具。通过 Go 语言实
14
14
 
15
15
  ## 安装
16
16
 
17
- ### 方式一:Homebrew(推荐)
17
+ ### 使用 npm(推荐)
18
18
 
19
19
  ```bash
20
- # 添加 tap(未来会支持)
21
- # brew tap forechoandlook/gssh
22
- # brew install gssh
23
-
24
- # 暂时使用手动安装方式
25
- git clone https://github.com/forechoandlook/gssh.git
26
- cd gssh
27
- go build -o bin/daemon cmd/daemon/main.go
28
- go build -o bin/gssh cmd/gssh/main.go
29
- ./homebrew/install.sh
20
+ npm install -g gssh-agent
30
21
  ```
31
22
 
32
- ### 方式二:直接安装
23
+ ### 手动安装
33
24
 
34
25
  ```bash
35
26
  # 克隆项目
@@ -45,53 +36,11 @@ cp bin/daemon /usr/local/bin/gssh-daemon
45
36
  cp bin/gssh /usr/local/bin/gssh
46
37
  ```
47
38
 
48
- ## 服务管理(macOS)
49
-
50
- ### 使用 launchctl
39
+ ## 启动服务
51
40
 
52
41
  ```bash
53
- # 启动服务
54
- launchctl start com.gssh.daemon
55
-
56
- # 停止服务
57
- launchctl stop com.gssh.daemon
58
-
59
- # 查看状态
60
- launchctl list | grep gssh
61
-
62
- # 卸载服务
63
- launchctl unload ~/Library/LaunchAgents/gssh.plist
64
- rm ~/Library/LaunchAgents/gssh.plist
65
- ```
66
-
67
- ### 使用 Homebrew services
68
-
69
- ```bash
70
- # 启动(首次安装后自动启动)
71
- brew services start gssh
72
-
73
- # 停止
74
- brew services stop gssh
75
-
76
- # 查看状态
77
- brew services list
78
-
79
- # 重启
80
- brew services restart gssh
81
- ```
82
-
83
- ### 使用 PM2(跨平台)
84
-
85
- ```bash
86
- # 安装 PM2
87
- npm install -g pm2
88
-
89
- # 启动 daemon
90
- pm2 start gssh-daemon.sh --name gssh
91
-
92
- # 保存并设置开机自启
93
- pm2 save
94
- pm2 startup
42
+ # 启动 gssh daemon
43
+ gssh-daemon
95
44
  ```
96
45
 
97
46
  ## 使用方法
@@ -99,7 +48,7 @@ pm2 startup
99
48
  ### 连接 SSH(密码认证)
100
49
 
101
50
  ```bash
102
- gssh connect -u admin1 -h 139.196.175.163 -p 7080 -P 1234
51
+ gssh connect -u admin1 -h xxxx -p xxxx -P xxxxx
103
52
  ```
104
53
 
105
54
  ### 连接 SSH(密钥认证)
@@ -116,6 +65,12 @@ gssh exec "ls -la"
116
65
 
117
66
  # 指定 session
118
67
  gssh exec -s <session_id> "pwd"
68
+
69
+ # 带超时命令
70
+ gssh exec -t 10 "ls -la"
71
+
72
+ # sudo 命令
73
+ gssh exec -S password "sudo systemctl restart nginx"
119
74
  ```
120
75
 
121
76
  ### 端口转发
@@ -123,16 +78,27 @@ gssh exec -s <session_id> "pwd"
123
78
  ```bash
124
79
  # 本地端口转发:本地 8080 -> 远程 80
125
80
  gssh forward -l 8080 -r 80
81
+
82
+ # 远程端口转发:远程 9000 -> 本地 3000
83
+ gssh forward -R -l 9000 -r 3000
84
+
85
+ # 列出所有端口转发
86
+ gssh forwards
87
+
88
+ # 关闭端口转发
89
+ gssh forward-close <forward_id>
126
90
  ```
127
91
 
128
- ### 文件传输(SFTP/SCP)
92
+ ### 文件传输与同步(SFTP/SCP/SYNC
129
93
 
130
94
  ```bash
131
- # 上传文件(本地 -> 远程)
95
+ # 上传文件或文件夹(本地 -> 远程)
132
96
  gssh scp -put /path/to/local/file.txt /path/to/remote/file.txt
97
+ gssh sync -put /path/to/local/dir /path/to/remote/dir
133
98
 
134
- # 下载文件(远程 -> 本地)
99
+ # 下载文件或文件夹(远程 -> 本地)
135
100
  gssh scp -get /path/to/remote/file.txt /path/to/local/file.txt
101
+ gssh sync -get /path/to/remote/dir /path/to/local/dir
136
102
 
137
103
  # 列出远程目录
138
104
  gssh sftp -c ls -p /path/to/remote/dir
@@ -178,6 +144,10 @@ gssh reconnect -s <session_id>
178
144
  | `-get` | 下载模式(远程 -> 本地) |
179
145
  | `-c command` | SFTP 命令(ls/mkdir/rm) |
180
146
  | `-p path` | SFTP 路径 |
147
+ | `-t timeout` | 命令超时时间(秒) |
148
+ | `-S password` | sudo 密码 |
149
+ | `--ask-pass` | 交互输入 SSH 密码 |
150
+ | `--ask-sudo-pass` | 交互输入 sudo 密码 |
181
151
 
182
152
  ## 开发
183
153
 
package/bin/gssh CHANGED
Binary file