From 5dfcef1eaba4b8563a7eb2865d28bf45be282f23 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 26 Jun 2020 07:21:58 +0700 Subject: environment: set the SSH key, user, host, and port By knowing this values, user can use it to invoke other SSH related command, for example to copy file using `scp` scp -i {{.SSHKey}} src {{.SSHUser}}@{{.SSHHost}}:{{.SSHPort}}/dst --- command.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'command.go') diff --git a/command.go b/command.go index cd6a86f..3a6d86f 100644 --- a/command.go +++ b/command.go @@ -401,4 +401,9 @@ func (cmd *Command) initSSHClient() { if err != nil { log.Fatal("cmd: cannot create new SSH client: " + err.Error()) } + + cmd.env.SSHKey = sshSection.IdentityFile[0] + cmd.env.SSHUser = sshSection.User + cmd.env.SSHHost = sshSection.Hostname + cmd.env.SSHPort = strconv.Itoa(sshSection.Port) } -- cgit v1.3-5-g9baa