"SSH exit-code 2" error occurs while running a ZAP scan from TeamCity

1,423 views
Skip to first unread message

Khopithan Sathiyakeerthy

unread,
Jun 5, 2021, 4:19:27 AM6/5/21
to OWASP ZAP User Group

Hi all,

When I run the below shown command in docker hosted vm directly, it runs well and generate a ZAP scan report without any errors.

docker run -v $(pwd)/zap-report:/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t http://example.com -r stable-baselinescan.html


But when I run the same command from teamcity, it runs well and generate report as well but it is exited with this "SSH exit-code 2" error
a.png


SSH exit code 2 means - Remote connection failure. But I don't see any connection failure. Hope u all help to figure out this issue

Regards,
Khopi

Simon Bennetts

unread,
Jun 7, 2021, 5:13:31 AM6/7/21
to OWASP ZAP User Group
Hiya Khopi,

The baseline scan will exit with a 2 as it has found some warnings.
The "SSH" part is nothing to do with ZAP - thats probably something to do with how TeamCity is invoking Docker.
But the '2', yes thats probably coming from ZAP and is as expected: https://github.com/zaproxy/zaproxy/blob/main/docker/zap-baseline.py#L31-L35

Cheers,

Simon

Khopithan Sathiyakeerthy

unread,
Jun 7, 2021, 5:48:50 AM6/7/21
to OWASP ZAP User Group
Hi Simon,

Thank you so much. I ran the command with -d argument and found the warnings. Then I generated the .conf file and changed the WARN as IGNORE. Then I ran again with the .conf file and made it successful build. 👍👍

Best
Khopi

Simon Bennetts

unread,
Jun 7, 2021, 6:13:50 AM6/7/21
to OWASP ZAP User Group
Great - thanks for letting us know!

Khopithan Sathiyakeerthy

unread,
Jun 7, 2021, 6:20:47 AM6/7/21
to OWASP ZAP User Group
Hi Simon,

Can you plz check this conversation 

Regards,
Khopi

Khopithan Sathiyakeerthy

unread,
Jul 7, 2021, 6:48:07 AM7/7/21
to OWASP ZAP User Group
Hi All,

FYI

If you want to run ZAP container scan from TeamCity without "SSH exit-code 2" error,

You need to add this part after your scanning command
2> /dev/null; (($? == 2)) && echo 'Done' >&2

E.g.
docker run -v $(pwd)/zap-report:/zap/wrk/:rw -t owasp/zap2docker-stable zap-full-scan.py -t https://example.com/myapp -j -a -r stable-full-scan-report.html 2> /dev/null; (($? == 2)) && echo 'Done' >&2 

Regards,
Khopi
Reply all
Reply to author
Forward
0 new messages