@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55you may not use this file except in compliance with the License.
66You may obtain a copy of the License at
77
8- http://www.apache.org/licenses/LICENSE-2.0
8+ http://www.apache.org/licenses/LICENSE-2.0
99
1010Unless required by applicable law or agreed to in writing, software
1111distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,7 +18,6 @@ package cmd
1818import (
1919 "fmt"
2020 "io"
21- "io/ioutil"
2221 "log"
2322 "net"
2423 "os"
@@ -27,7 +26,7 @@ import (
2726
2827 "github.com/spf13/cobra"
2928 gossh "golang.org/x/crypto/ssh"
30- "golang.org/x/crypto/ssh/terminal "
29+ "golang.org/x/term "
3130)
3231
3332var (
@@ -95,20 +94,19 @@ jmstool ssh root@127.0.0.1 -p 2222
9594 auths = append (auths , gossh .Password (password ))
9695 }
9796
98-
9997 if password == "" && privateFile == "" {
10098 if _ , err := fmt .Fprintf (os .Stdout , "%s@%s password: " , username , host ); err != nil {
10199 log .Fatal (err )
102100 }
103- if result , err := terminal .ReadPassword (int (os .Stdout .Fd ())); err != nil {
101+ if result , err := term .ReadPassword (int (os .Stdout .Fd ())); err != nil {
104102 log .Fatal (err )
105103 } else {
106104 auths = append (auths , gossh .Password (string (result )))
107105 }
108106
109107 }
110108 if privateFile != "" {
111- raw , err := ioutil .ReadFile (privateFile )
109+ raw , err := os .ReadFile (privateFile )
112110 if err != nil {
113111 log .Fatal (err )
114112 }
@@ -147,7 +145,7 @@ jmstool ssh root@127.0.0.1 -p 2222
147145 xterm = "xterm-256color"
148146 }
149147 fd := int (os .Stdin .Fd ())
150- w , h , _ := terminal .GetSize (fd )
148+ w , h , _ := term .GetSize (fd )
151149 err = sess .RequestPty (xterm , h , w , modes )
152150 if err != nil {
153151 log .Fatalf ("RequestPty err: %s" , err )
@@ -160,11 +158,11 @@ jmstool ssh root@127.0.0.1 -p 2222
160158 if err != nil {
161159 log .Fatalf ("StdoutPipe err: %s" , err )
162160 }
163- state , err := terminal .MakeRaw (fd )
161+ state , err := term .MakeRaw (fd )
164162 if err != nil {
165163 log .Fatalf ("MakeRaw err: %s" , err )
166164 }
167- defer terminal .Restore (fd , state )
165+ defer term .Restore (fd , state )
168166
169167 go io .Copy (in , os .Stdin )
170168 go io .Copy (os .Stdout , out )
@@ -186,7 +184,7 @@ jmstool ssh root@127.0.0.1 -p 2222
186184 if sigwinch == nil {
187185 return
188186 }
189- w , h , err := terminal .GetSize (fd )
187+ w , h , err := term .GetSize (fd )
190188 if err != nil {
191189 log .Printf ("Unable to send window-change reqest: %s. \n " , err )
192190 continue
@@ -210,6 +208,7 @@ func init() {
210208 sshCmd .PersistentFlags ().StringP ("port" , "p" , "22" , "ssh port" )
211209 sshCmd .PersistentFlags ().StringP ("password" , "P" , "" , "ssh password" )
212210 sshCmd .PersistentFlags ().StringP ("identity" , "i" , "" , "identity_file" )
211+ sshCmd .PersistentFlags ().StringP ("config" , "c" , "" , "config file for cipher, kex, hostkey" )
213212 // Here you will define your flags and configuration settings.
214213
215214 // Cobra supports Persistent Flags which will work for this command
0 commit comments