Skip to content

Commit

Permalink
ssh: fix for snap
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgersh authored and Zach Gershman committed Dec 10, 2019
1 parent 8824f76 commit a6932b8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ limitations under the License.
package ssh

import (
"github.com/digitalocean/doctl/pkg/runner"
"fmt"
"os"
"os/exec"
"strconv"

"github.com/digitalocean/doctl/pkg/runner"
"github.com/fatih/color"
)

// Options is the type used to specify options passed to the SSH command
Expand Down Expand Up @@ -66,5 +69,18 @@ func (r *Runner) Run() error {
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin

return cmd.Run()
err := cmd.Run()
if err != nil {
_, isSnap := os.LookupEnv("SNAP")

if os.IsPermission(err) && isSnap {
msg := "Using the doctl Snap? Grant access to the ssh-keys interface with this command: sudo snap connect doctl:ssh-keys :ssh-keys"
fmt.Fprintf(color.Error, "%s: %s", color.YellowString("Warning"), msg)
return err
}

return err
}

return nil
}

0 comments on commit a6932b8

Please sign in to comment.