diff --git a/cmd/rdp.go b/cmd/rdp.go index 403363d..ca0be5f 100644 --- a/cmd/rdp.go +++ b/cmd/rdp.go @@ -66,8 +66,9 @@ func ConnectToServerRDP(user, host, credentialKey string) { _, err := exec.LookPath("xfreerdp") if err != nil { - logrus.Fatalln(color.InRed("xfreerdp is not installed or not in PATH. Please install it and try again.")) - return + logrus.Infoln(color.InRed("xfreerdp is not installed or not in PATH. Please install it and try again.")) + logrus.Infoln("Required packages: pkg-mgr install xfreerdp xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-xinit xorg-x11-xdm -y") + os.Exit(0) } if os.Getenv("DISPLAY") == "" { @@ -84,6 +85,7 @@ func ConnectToServerRDP(user, host, credentialKey string) { if err != nil { logrus.Fatal(color.InRed("Error reading password")) } + security.StoreCredentials(credentialKey, password) } else { password = retrievedPassword } @@ -98,14 +100,13 @@ func ConnectToServerRDP(user, host, credentialKey string) { // Add a delay to ensure environment is set time.Sleep(2 * time.Second) - var cmd *exec.Cmd - args := []string{ fmt.Sprintf("/u:%s", user), fmt.Sprintf("/p:%s", string(password)), fmt.Sprintf("/v:%s", host), "+clipboard", "/dynamic-resolution", + "/cert:ignore", "/compression-level:2", "/scale:100", "/scale-desktop:100", @@ -121,7 +122,7 @@ func ConnectToServerRDP(user, host, credentialKey string) { args = append(args, "/log-level:TRACE", "/log-filters:*:TRACE") } - cmd = exec.Command("xfreerdp", args...) + cmd := exec.Command("xfreerdp", args...) if verbose { cmd.Stdout = os.Stdout diff --git a/internal/security/credentials.go b/internal/security/credentials.go index 3121be1..26db9f9 100644 --- a/internal/security/credentials.go +++ b/internal/security/credentials.go @@ -15,7 +15,7 @@ func StoreCredentials(key, value string) error { func RetreiveCredentials(key string) (string, error) { password, err := keyring.Get(appName, key) if err != nil { - return "", fmt.Errorf("error fetching credentials", err) + return "", fmt.Errorf("error fetching credentials %v", err) } return password, nil } diff --git a/internal/ssh/connect.go b/internal/ssh/connect.go index 3935186..78d80e2 100644 --- a/internal/ssh/connect.go +++ b/internal/ssh/connect.go @@ -3,15 +3,16 @@ package ssh import ( "errors" "fmt" - "github.com/TwiN/go-color" - "github.com/sirupsen/logrus" - "golang.org/x/crypto/ssh" "os" "os/exec" "path/filepath" "runtime" "syscall" "time" + + "github.com/TwiN/go-color" + "github.com/sirupsen/logrus" + "golang.org/x/crypto/ssh" ) func Connect(user, server string) { @@ -25,12 +26,10 @@ func Connect(user, server string) { var sshCmd *exec.Cmd switch runtime.GOOS { case "linux": - sshCmd = exec.Command("ssh", user+"@"+server) + sshCmd = exec.Command("ssh -X", user+"@"+server) case "darwin": sshCmd = exec.Command("ssh", user+"@"+server) case "windows": - //logrus.Error(color.InRed("SSH connection not implemented for Windows systems yet")) - //return sshCmd = exec.Command("ssh", user+"@"+server) default: logrus.Error(color.InRed("Unsupported operating system"))