mirror of
				https://github.com/appleboy/drone-ssh.git
				synced 2025-10-29 00:51:15 +08:00 
			
		
		
		
	Allows to specify IP protocol, including IPv4 only
This commit is contained in:
		
							parent
							
								
									ba70ad67ca
								
							
						
					
					
						commit
						62ca12a1d1
					
				
							
								
								
									
										19
									
								
								DOCS.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								DOCS.md
									
									
									
									
									
								
							| @ -178,6 +178,23 @@ Example configuration for passphrase which protecting a private key: | ||||
|         - echo "you can't see the steps." | ||||
| ``` | ||||
| 
 | ||||
| Example configuration for forcing protocol to IPv4 only: | ||||
| 
 | ||||
| ```diff | ||||
|   - name: ssh commands | ||||
|     image: ghcr.io/appleboy/drone-ssh | ||||
|     settings: | ||||
|       host: foo.com | ||||
|       username: root | ||||
|       password: 1234 | ||||
|       port: 22 | ||||
| +     protocol: tcp4 | ||||
|       script: | ||||
|         - echo hello | ||||
|         - echo world | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
| ## Secret Reference | ||||
| 
 | ||||
| | Key | Description | | ||||
| @ -197,6 +214,7 @@ Example configuration for passphrase which protecting a private key: | ||||
| |-----|-------------| | ||||
| | `host` | target hostname or IP | | ||||
| | `port` | ssh port of target host | | ||||
| | `protocol` | IP protocol to use: either tcp, tcp4 or tcp6 | | ||||
| | `username` | account for target host user | | ||||
| | `password` | password for target host user | | ||||
| | `key` | plain text of user private key | | ||||
| @ -208,6 +226,7 @@ Example configuration for passphrase which protecting a private key: | ||||
| | `command_timeout` | Command timeout is the maximum amount of time for the execute commands, default is 10 minutes. | | ||||
| | `proxy_host` | proxy hostname or IP | | ||||
| | `proxy_port` | ssh port of proxy host | | ||||
| | `proxy_protocol` | IP protocol to use for the proxy: either tcp, tcp4 or tcp6 | | ||||
| | `proxy_username` | account for proxy host user | | ||||
| | `proxy_password` | password for proxy host user | | ||||
| | `proxy_key` | plain text of proxy private key | | ||||
|  | ||||
							
								
								
									
										6
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								go.mod
									
									
									
									
									
								
							| @ -3,11 +3,11 @@ module github.com/appleboy/drone-ssh | ||||
| go 1.18 | ||||
| 
 | ||||
| require ( | ||||
| 	github.com/appleboy/easyssh-proxy v1.3.10 | ||||
| 	github.com/appleboy/easyssh-proxy v1.3.11-0.20230609114136-a50c12e64039 | ||||
| 	github.com/joho/godotenv v1.5.1 | ||||
| 	github.com/stretchr/testify v1.8.2 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| 	github.com/urfave/cli/v2 v2.25.3 | ||||
| 	golang.org/x/crypto v0.8.0 | ||||
| 	golang.org/x/crypto v0.9.0 | ||||
| ) | ||||
| 
 | ||||
| require ( | ||||
|  | ||||
							
								
								
									
										7
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								go.sum
									
									
									
									
									
								
							| @ -2,6 +2,8 @@ github.com/ScaleFT/sshkeys v1.2.0 h1:5BRp6rTVIhJzXT3VcUQrKgXR8zWA3sOsNeuyW15WUA8 | ||||
| github.com/ScaleFT/sshkeys v1.2.0/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o= | ||||
| github.com/appleboy/easyssh-proxy v1.3.10 h1:iriF68tlrYoxgWhS7t7Wyr0FA+hJlOem5tMfm+RDlx4= | ||||
| github.com/appleboy/easyssh-proxy v1.3.10/go.mod h1:T81pu/Cxx/zf/7YXhFCFiucBa4xeQ81ci5b0PFnMRJc= | ||||
| github.com/appleboy/easyssh-proxy v1.3.11-0.20230609114136-a50c12e64039 h1:u1o1Ft7PltG4+iOAmEubuyXx5fiDHWIvP+JiCClL+ak= | ||||
| github.com/appleboy/easyssh-proxy v1.3.11-0.20230609114136-a50c12e64039/go.mod h1:6nn1KPv9GP9BrK8tgl+d/w68jX4rpLeooO3FAcC/lds= | ||||
| github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= | ||||
| github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| @ -23,6 +25,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= | ||||
| github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| github.com/urfave/cli/v2 v2.25.3 h1:VJkt6wvEBOoSjPFQvOkv6iWIrsJyCrKGtCtxXWwmGeY= | ||||
| github.com/urfave/cli/v2 v2.25.3/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= | ||||
| github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= | ||||
| @ -31,6 +35,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk | ||||
| golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||||
| golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= | ||||
| golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= | ||||
| golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= | ||||
| golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= | ||||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| @ -38,6 +44,7 @@ golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7w | ||||
| golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= | ||||
| golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= | ||||
| golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
|  | ||||
							
								
								
									
										14
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								main.go
									
									
									
									
									
								
							| @ -51,6 +51,12 @@ func main() { | ||||
| 			EnvVars: []string{"PLUGIN_PORT", "SSH_PORT", "INPUT_PORT"}, | ||||
| 			Value:   22, | ||||
| 		}, | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "protocol", | ||||
| 			Usage:   "The IP protocol to use. Default to tcp (both IPv4 and IPv6).", | ||||
| 			EnvVars: []string{"PLUGIN_PROTOCOL", "SSH_PROTOCOL", "INPUT_PROTOCOL"}, | ||||
| 			Value:   "tcp", | ||||
| 		}, | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "username", | ||||
| 			Aliases: []string{"user", "u"}, | ||||
| @ -141,6 +147,12 @@ func main() { | ||||
| 			EnvVars: []string{"PLUGIN_PROXY_PORT", "PROXY_SSH_PORT", "INPUT_PROXY_PORT"}, | ||||
| 			Value:   "22", | ||||
| 		}, | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "proxy.protocol", | ||||
| 			Usage:   "The IP protocol to use for the proxy. Default to tcp (both IPv4 and IPv6).", | ||||
| 			EnvVars: []string{"PLUGIN_PROTOCOL", "SSH_PROTOCOL", "INPUT_PROTOCOL"}, | ||||
| 			Value:   "tcp", | ||||
| 		}, | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "proxy.username", | ||||
| 			Usage:   "connect as user of proxy", | ||||
| @ -259,6 +271,7 @@ func run(c *cli.Context) error { | ||||
| 			Fingerprint:       c.String("fingerprint"), | ||||
| 			Host:              c.StringSlice("host"), | ||||
| 			Port:              c.Int("port"), | ||||
| 			Protocol:          easyssh.Protocol(c.String("protocol")), | ||||
| 			Timeout:           c.Duration("timeout"), | ||||
| 			CommandTimeout:    c.Duration("command.timeout"), | ||||
| 			Script:            scripts, | ||||
| @ -278,6 +291,7 @@ func run(c *cli.Context) error { | ||||
| 				Fingerprint:       c.String("proxy.fingerprint"), | ||||
| 				Server:            c.String("proxy.host"), | ||||
| 				Port:              c.String("proxy.port"), | ||||
| 				Protocol:          easyssh.Protocol(c.String("proxy.protocol")), | ||||
| 				Timeout:           c.Duration("proxy.timeout"), | ||||
| 				Ciphers:           c.StringSlice("proxy.ciphers"), | ||||
| 				UseInsecureCipher: c.Bool("proxy.useInsecureCipher"), | ||||
|  | ||||
| @ -30,6 +30,7 @@ type ( | ||||
| 		Password          string | ||||
| 		Host              []string | ||||
| 		Port              int | ||||
| 		Protocol          easyssh.Protocol | ||||
| 		Fingerprint       string | ||||
| 		Timeout           time.Duration | ||||
| 		CommandTimeout    time.Duration | ||||
| @ -75,6 +76,7 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { | ||||
| 		User:              p.Config.Username, | ||||
| 		Password:          p.Config.Password, | ||||
| 		Port:              port, | ||||
| 		Protocol:          p.Config.Protocol, | ||||
| 		Key:               p.Config.Key, | ||||
| 		KeyPath:           p.Config.KeyPath, | ||||
| 		Passphrase:        p.Config.Passphrase, | ||||
| @ -87,6 +89,7 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { | ||||
| 			User:              p.Config.Proxy.User, | ||||
| 			Password:          p.Config.Proxy.Password, | ||||
| 			Port:              p.Config.Proxy.Port, | ||||
| 			Protocol:          p.Config.Proxy.Protocol, | ||||
| 			Key:               p.Config.Proxy.Key, | ||||
| 			KeyPath:           p.Config.Proxy.KeyPath, | ||||
| 			Passphrase:        p.Config.Proxy.Passphrase, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Yoan Tournade
						Yoan Tournade