3 Commits

Author SHA1 Message Date
9c202cf3e9 Merge branch 'develop' 2023-02-02 11:28:35 -06:00
c3fa74e442 fix for remote host ports 2023-02-02 11:24:01 -06:00
0f3cf0d9c4 changed .goreleaser.yaml 2023-02-02 00:15:53 -06:00
2 changed files with 19 additions and 23 deletions

View File

@ -14,7 +14,7 @@ archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_{{ .Version }}_
{{ .ProjectName }}
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386

View File

@ -73,7 +73,7 @@ func (remoteConfig *Host) ConnectToSSHHost(log *zerolog.Logger) (*ssh.Client, er
remoteConfig.GetPrivateKeyFromConfig()
remoteConfig.GetHostNameWithPort()
remoteConfig.GetSshUserFromConfig()
log.Info().Msgf("Port: %v", remoteConfig.Port)
if remoteConfig.HostName == "" {
return nil, errors.New("No hostname found or specified")
}
@ -175,17 +175,19 @@ func (remoteHost *Host) GetPrivateKeyFromConfig() {
remoteHost.PrivateKeyPath, _ = resolveDir(identityFile)
}
// GetHostNameWithPort checks if the port from the config file is empty
// If it is the port is searched in the SSH config file
// GetHostNameWithPort checks if the port from the config file is 0
// If it is the port is searched in the SSH config file(s)
func (remoteHost *Host) GetHostNameWithPort() {
var port string
port := fmt.Sprintf("%v", remoteHost.Port)
if remoteHost.Port == 0 {
if remoteHost.HostName == "" {
remoteHost.HostName, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "HostName")
if remoteHost.HostName == "" {
remoteHost.HostName = remoteHost.SSHConfigFile.DefaultUserSettings.Get(remoteHost.Host, "HostName")
}
}
// no port specifed
if port == "0" {
port, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "Port")
if port == "" {
port = remoteHost.SSHConfigFile.DefaultUserSettings.Get(remoteHost.Host, "Port")
@ -193,16 +195,10 @@ func (remoteHost *Host) GetHostNameWithPort() {
port = "22"
}
}
println(port)
}
if !strings.HasSuffix(remoteHost.HostName, ":"+port) {
remoteHost.HostName = remoteHost.HostName + ":" + port
} else {
if remoteHost.HostName == "" {
remoteHost.HostName, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "HostName")
if remoteHost.HostName == "" {
remoteHost.HostName = remoteHost.SSHConfigFile.DefaultUserSettings.Get(remoteHost.Host, "HostName")
}
}
remoteHost.HostName = remoteHost.HostName + ":" + fmt.Sprintf("%v", remoteHost.Port)
}
}