drone-ssh: panic: runtime error: invalid memory address or nil pointer dereference
For
deploy:
image: appleboy/drone-ssh
host: example.dev
user: nemonik
port: 22
key: ${SSH_KEY}
script:
- echo "Hey"
- ls
when:
branch:
include: [ master, release/* ]
After registering my SSH_KEY as a secret via drone cli
drone secret add --image=appleboy/drone-ssh Ephemeral/nodejs-helloworld SSH_KEY "$(cat ~/.ssh/privatekey)"
I get out of drone:
2017/02/09 05:15:32 example.dev commands: echo "Hey"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x54e043]
goroutine 18 [running]:
panic(0x62b220, 0xc42000a060)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh.publicKeyCallback.auth(0xc42007f560, 0xc420010d40, 0x20, 0x20, 0xc42006cb10, 0x7, 0x772a00, 0xc4200e8000, 0x770600, 0xc4200705d0, ...)
/srv/app/src/github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh/client_auth.go:191 +0xb3
github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh.(*connection).clientAuthenticate(0xc4200dc100, 0xc4200e0000, 0x0, 0xa)
/srv/app/src/github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh/client_auth.go:34
github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh.(*connection).clientHandshake(0xc4200dc100, 0xc420070db0, 0x22, 0xc4200e0000, 0x0, 0x0)
/srv/app/src/github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh/client.go:107 +0x2ed
github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh.NewClientConn(0x774b20, 0xc42002a008, 0xc420070db0, 0x22, 0xc420069a90, 0x774b20, 0xc42002a008, 0x0, 0x0, 0xc42007f560, ...)
/srv/app/src/github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh/client.go:75 +0x105
github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh.Dial(0x666e8c, 0x3, 0xc420070db0, 0x22, 0xc420069a90, 0x22, 0x0, 0x1)
/srv/app/src/github.com/appleboy/drone-ssh/vendor/golang.org/x/crypto/ssh/client.go:171 +0xb3
github.com/appleboy/drone-ssh/easyssh.(*MakeConfig).connect(0xc420069e90, 0x45c000, 0x10000c42007c010, 0x0)
/srv/app/src/github.com/appleboy/drone-ssh/easyssh/easyssh.go:77 +0x16b
github.com/appleboy/drone-ssh/easyssh.(*MakeConfig).Stream(0xc420069e90, 0xc42006cbf0, 0xd, 0xd, 0xd, 0xc420069ca8, 0x4431ce)
/srv/app/src/github.com/appleboy/drone-ssh/easyssh/easyssh.go:95 +0x40
github.com/appleboy/drone-ssh/easyssh.(*MakeConfig).Run(0xc420069e90, 0xc42006cbf0, 0xd, 0x666c32, 0x1, 0xc42006cbf0, 0xd)
/srv/app/src/github.com/appleboy/drone-ssh/easyssh/easyssh.go:130 +0x5d
main.Plugin.Exec.func1(0xc42006cac6, 0xa, 0x0, 0x0, 0xc42006cb10, 0x7, 0x0, 0x0, 0xc42006c940, 0x1, ...)
/srv/app/src/github.com/appleboy/drone-ssh/plugin.go:71 +0x330
created by main.Plugin.Exec
/srv/app/src/github.com/appleboy/drone-ssh/plugin.go:79 +0x16e
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 52 (17 by maintainers)
@PeterCat12 and @appleboy:
So, awoke with the solution.
If you set a
SHH_KEY
secret like soAnd then set up the pipeline like so:
The container/plugin will have an SSH_KEY environmental variable containing the text of your private key, but a PLUGIN_KEY environmental variable containing, well, ${SSH_KEY}. The SSH_KEY environmental variable is ignored, but the PLUGIN_KEY environmental is used to set p.Config.Key and this goes in easydrone to attempt the SSH connection resulting in a fail.
One has to understand all these parameters show up in the container/plugin prepended with
PLUGIN
_ and then the all caps form of the parameter.So, your
drone secret rm
the SSH_KEY and instead set a PLUGIN_KEY like soand the modify your pipeline to:
Yeah, you don’t even pass a
key
value as it already exists as secret. Trigger your build and things run fine like so:I would suggest updating the documentation.
For
drone/drone:0.5
and drone CLI version 0.5.0+dev, it is stil a great big fail whale.Okay. Every step:
Then
ls -las ~/.ssh
returns:Add the private kek:
View via
drone secret ls Ephemeral/nodejs-helloworld
returns:Sign my project:
For this .drone.yml:
I get:
If I run
appleboy/drone-ssh
on the command line like soI get:
@PeterCat12, I cloned the appleboy/drone-ssh repo, added logging to print out
p
inside the Exec function in plugin.go to verify envs were being passed, then built the image.I added SSH_KEY_PATH and SSH_KEY secrets via drone respectfully like so
Passing SSH_KEY_PATH ephemeral/drone-ssh spits out
for .drone.yml entry
And then for the SSH_KEY
for .drone.yml entry
Am I missing something like fundamentally stupid?
So
Modified for my environment works returning: