utils

created pr with 99.1 on 2025-12-25T04:21:37Z · by c8ef7d19
added 99.2 on 2025-12-25T04:22:52Z · by c8ef7d19
1: b41f14a ! 1: dca5cae feat: add ssh cert file support to ssh client impl
added 99.3 on 2025-12-25T20:00:24Z · by c8ef7d19
1: dca5cae = 1: dca5cae feat: add ssh cert file support to ssh client impl
-: ------- > 2: 31cd283 refactor: CertificateFile -> CertificateLocation
cmds
checkout latest patchset:
ssh pr.pico.sh print 99 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 99.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 99

Patchset 99.3 on 2025-12-25T20:00:24Z · commit dca5cae

+33 -5 pipe/client.go #
......@@ -182,11 +182,12 @@ func (c *Client) RemoveSession(id string) error {
182182
183183 // SSHClientInfo represents the SSH connection information.
184184 type SSHClientInfo struct {
185- RemoteHost string
186- RemoteHostname string
187- RemoteUser string
188- KeyLocation string
189- KeyPassphrase string
185+ RemoteHost string
186+ RemoteHostname string
187+ RemoteUser string
188+ KeyLocation string
189+ KeyPassphrase string
190+ CertificateFile string
190191 }
191192
192193 // NewSSHClient creates a new SSH client.
......@@ -226,6 +227,33 @@ func NewSSHClient(info *SSHClientInfo) (*ssh.Client, error) {
226227 if err != nil {
227228 return nil, err
228229 }
230+
231+ if info.CertificateFile != "" {
232+ certPath, err := filepath.Abs(info.CertificateFile)
233+ if err != nil {
234+ return nil, err
235+ }
236+
237+ certData, err := os.ReadFile(certPath)
238+ if err != nil {
239+ return nil, err
240+ }
241+
242+ pubKey, _, _, _, err := ssh.ParseAuthorizedKey(certData)
243+ if err != nil {
244+ return nil, fmt.Errorf("failed to parse certificate: %w", err)
245+ }
246+
247+ cert, ok := pubKey.(*ssh.Certificate)
248+ if !ok {
249+ return nil, fmt.Errorf("file is not an SSH certificate")
250+ }
251+
252+ signer, err = ssh.NewCertSigner(cert, signer)
253+ if err != nil {
254+ return nil, fmt.Errorf("failed to create cert signer: %w", err)
255+ }
256+ }
229257 }
230258
231259 var authMethods []ssh.AuthMethod
Back to top