Skip to content

Commit

Permalink
feat: Get keys from locked SSH agents 馃攼
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFantom committed Dec 22, 2022
1 parent 7aa6b82 commit 8423e4c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/sshare/sshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
transferDownloads int = 0
transferDays int = 0
sshAgentPath string = os.Getenv("SSH_AUTH_SOCK")
sshAgentPass string = ""
keyFilepaths []string = make([]string, 0)
)

Expand Down Expand Up @@ -41,7 +42,11 @@ var (
chosenKeys = append(chosenKeys, k)
}
if sshAgentPath != "" {
sshAgent, err := keys.NewSSHAgent(sshAgentPath)
agentOpts := make([]keys.AgentOpt, 0)
if sshAgentPass != "" {
agentOpts = append(agentOpts, keys.AgentPassphraseOpt(sshAgentPass))
}
sshAgent, err := keys.NewSSHAgent(sshAgentPath, agentOpts...)
if err != nil {
ui.Errorln(err.Error(), true)
}
Expand Down Expand Up @@ -84,6 +89,7 @@ func main() {

func init() {
rootCmd.PersistentFlags().StringVarP(&sshAgentPath, "agent", "a", sshAgentPath, "Path to the target SSH Agent socket")
rootCmd.PersistentFlags().StringVarP(&sshAgentPass, "passphrase", "p", sshAgentPass, "Passphrase for the SSH agent")
rootCmd.PersistentFlags().StringArrayVarP(&keyFilepaths, "key-file", "k", keyFilepaths, "Additional key file(s) to include in the generated authorized_keys")
rootCmd.PersistentFlags().IntVarP(&transferDownloads, "max-downloads", "m", 10, "Maximum number of times any content shared can be downloaded")
rootCmd.PersistentFlags().IntVarP(&transferDays, "max-days", "d", 2, "Number of days that the content will remain available via transfer.sh")
Expand Down

0 comments on commit 8423e4c

Please sign in to comment.