aboutsummaryrefslogtreecommitdiff
path: root/command.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-06-26 07:21:58 +0700
committerShulhan <m.shulhan@gmail.com>2020-06-26 07:21:58 +0700
commit5dfcef1eaba4b8563a7eb2865d28bf45be282f23 (patch)
tree9ea3346fde7bfb79468719665bf4f2a1a77b867b /command.go
parentf370c2a598d3b4482e2d391458fc6878fada49af (diff)
downloadawwan-5dfcef1eaba4b8563a7eb2865d28bf45be282f23.tar.xz
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
Diffstat (limited to 'command.go')
-rw-r--r--command.go5
1 files changed, 5 insertions, 0 deletions
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)
}