Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ brew install(Mac OS X)

## Config

Please edit "~/.lssh.conf".\
For details see [wiki](https://github.com/blacknon/lssh/wiki/Config).
Default configuration file is either "~/.lssh.conf" or "~/.config/lssh/lssh.conf",
the later being used if both exists.

For details about configuration file content see [wiki](https://github.com/blacknon/lssh/wiki/Config).

## Usage

Expand All @@ -81,7 +83,7 @@ option(lssh)

OPTIONS:
--host servername, -H servername connect servername.
--file filepath, -F filepath config filepath. (default: "/Users/blacknon/.lssh.conf")
--file filepath, -F filepath, -f filepath config filepath. (default: "/Users/blacknon/.lssh.conf")
-L [bind_address:]port:remote_address:port Local port forward mode.Specify a [bind_address:]port:remote_address:port.
-R [bind_address:]port:remote_address:port Remote port forward mode.Specify a [bind_address:]port:remote_address:port.
-D port Dynamic port forward mode(Socks5). Specify a port.
Expand Down
3 changes: 3 additions & 0 deletions cmd/lscp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func Lscp() (app *cli.App) {
// Default config file path
usr, _ := user.Current()
defConf := usr.HomeDir + "/.lssh.conf"
if _, err := os.Stat(usr.HomeDir + "/.config/lssh/lssh.conf"); err == nil {
defConf = usr.HomeDir + "/.config/lssh/lssh.conf"
}

// Set help templete
cli.AppHelpTemplate = `NAME:
Expand Down
3 changes: 3 additions & 0 deletions cmd/lsftp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func Lsftp() (app *cli.App) {
// Default config file path
usr, _ := user.Current()
defConf := usr.HomeDir + "/.lssh.conf"
if _, err := os.Stat(usr.HomeDir + "/.config/lssh/lssh.conf"); err == nil {
defConf = usr.HomeDir + "/.config/lssh/lssh.conf"
}

// Set help templete
cli.AppHelpTemplate = `NAME:
Expand Down
5 changes: 4 additions & 1 deletion cmd/lssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func Lssh() (app *cli.App) {
// Default config file path
usr, _ := user.Current()
defConf := usr.HomeDir + "/.lssh.conf"
if _, err := os.Stat(usr.HomeDir + "/.config/lssh/lssh.conf"); err == nil {
defConf = usr.HomeDir + "/.config/lssh/lssh.conf"
}

// Set help templete
cli.AppHelpTemplate = `NAME:
Expand Down Expand Up @@ -79,7 +82,7 @@ USAGE:
app.Flags = []cli.Flag{
// common option
cli.StringSliceFlag{Name: "host,H", Usage: "connect `servername`."},
cli.StringFlag{Name: "file,F", Value: defConf, Usage: "config `filepath`."},
cli.StringFlag{Name: "file,F,f", Value: defConf, Usage: "config `filepath`."},

// port forward option
cli.StringFlag{Name: "L", Usage: "Local port forward mode.Specify a `[bind_address:]port:remote_address:port`."},
Expand Down
10 changes: 9 additions & 1 deletion ssh/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/blacknon/go-sshlib"
"github.com/blacknon/lssh/common"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/terminal"
)

const SSH_AUTH_SOCK = "SSH_AUTH_SOCK"
Expand Down Expand Up @@ -42,7 +43,14 @@ func (r *Run) CreateAuthMethodMap() {

// Password
if config.Pass != "" {
r.registAuthMapPassword(server, config.Pass)
if config.Pass == "ask" {
fmt.Print("Enter password: ")
stdinPass, _ := terminal.ReadPassword(int(os.Stdin.Fd()));
fmt.Printf("\n")
r.registAuthMapPassword(server, strings.TrimSpace(string(stdinPass)))
} else {
r.registAuthMapPassword(server, config.Pass)
}
}

// Multiple Password
Expand Down
14 changes: 7 additions & 7 deletions ssh/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ func (r *Run) Start() {
// use ssh login header.
func (r *Run) PrintSelectServer() {
serverListStr := strings.Join(r.ServerList, ",")
fmt.Fprintf(os.Stderr, "Select Server :%s\n", serverListStr)
fmt.Fprintf(os.Stderr, "Select Server : %s\n", serverListStr)
}

// printRunCommand is printout run command.
// use ssh command run header.
func (r *Run) printRunCommand() {
runCmdStr := strings.Join(r.ExecCmd, " ")
fmt.Fprintf(os.Stderr, "Run Command :%s\n", runCmdStr)
fmt.Fprintf(os.Stderr, "Run Command : %s\n", runCmdStr)
}

// printPortForward is printout port forwarding.
Expand All @@ -194,17 +194,17 @@ func (r *Run) printPortForward(m, forwardLocal, forwardRemote string) {
arrow = "<= "
}

fmt.Fprintf(os.Stderr, "Port Forward :%s\n", mode)
fmt.Fprintf(os.Stderr, " local[%s] %s remote[%s]\n", forwardLocal, arrow, forwardRemote)
fmt.Fprintf(os.Stderr, "Port Forward : %s\n", mode)
fmt.Fprintf(os.Stderr, " local[%s] %s remote[%s]\n", forwardLocal, arrow, forwardRemote)
}
}

// printPortForward is printout port forwarding.
// use ssh command run header. only use shell().
func (r *Run) printDynamicPortForward(port string) {
if port != "" {
fmt.Fprintf(os.Stderr, "DynamicForward:%s\n", port)
fmt.Fprintf(os.Stderr, " %s\n", "connect Socks5.")
fmt.Fprintf(os.Stderr, "DynamicForward : %s\n", port)
fmt.Fprintf(os.Stderr, " %s\n", "connect Socks5.")
}
}

Expand Down Expand Up @@ -251,7 +251,7 @@ func (r *Run) printProxy(server string) {

// print header
header := strings.Join(array, " => ")
fmt.Fprintf(os.Stderr, "Proxy :%s\n", header)
fmt.Fprintf(os.Stderr, "Proxy : %s\n", header)
}

// runCmdLocal exec command local machine.
Expand Down