Error opening SSH connection: ssh: handshake failed: Unsupported host key fingerprint format
Command
cf ssh
CLI Version
cf version 6.17.0+5d0be0a-2016-04-15
Error
FAILED
Error opening SSH connection: ssh: handshake failed: Unsupported host key fingerprint format
The cli does not support app ssh fingerprints using SHA256 encryption, most ssh fingerprints are md5. This is most likely an issue with the ssh connection code as connecting with openSSH works.
Stack Trace
None.
CC API Version
CF v233.
CF Trace
FAILED
Incorrect Usage
Invalid flag: --cf-trace=true
NAME:
ssh - SSH to an application container instance
USAGE:
cf ssh APP_NAME [-i app-instance-index] [-c command] [-L [bind_address:]port:host:hostport] [--skip-host-validation] [--skip-remote-execution] [--request-pseudo-tty] [--force-pseudo-tty] [--disable-pseudo-tty]
OPTIONS:
-L Local port forward specification. This flag can be defined more than once.
--app-instance-index, -i Application instance index
--command, -c Command to run. This flag can be defined more than once.
--disable-pseudo-tty, -T Disable pseudo-tty allocation
--force-pseudo-tty, -tt Force pseudo-tty allocation
--request-pseudo-tty, -t Request pseudo-tty allocation
--skip-host-validation, -k Skip host key validation
--skip-remote-execution, -N Do not execute a remote command
2016-04-15 15:33:40 ☆ ruby 2.1.7p400 kearny in ~/workspace/deployments-runtime/runtime1
± rd |master U:2 ✗| → CF_TRACE=true cf ssh dora
REQUEST: [2016-04-15T15:33:58-07:00]
GET /v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/apps?q=name%3Adora&inline-relations-depth=1 HTTP/1.1
Host: api.runtime1.cf-app.com
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: go-cli 6.17.0+5d0be0a / darwin
RESPONSE: [2016-04-15T15:33:59-07:00]
HTTP/1.1 200 OK
Content-Length: 4907
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Date: Fri, 15 Apr 2016 22:33:59 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Vcap-Request-Id: acee3112-a994-44f3-41d5-7531bcb6cc38
X-Vcap-Request-Id: 2d817506-22fa-4b68-6de9-6bb94beeaf64::948f3dfa-fd8c-4bde-860a-2dfb5e6eea83
{
"total_results": 1,
"total_pages": 1,
"prev_url": null,
"next_url": null,
"resources": [
{
"metadata": {
"guid": "4a0ebffe-8733-4dee-837e-0bdf7af939cb",
"url": "/v2/apps/4a0ebffe-8733-4dee-837e-0bdf7af939cb",
"created_at": "2016-04-14T21:24:00Z",
"updated_at": "2016-04-15T16:36:22Z"
},
"entity": {
"name": "dora",
"production": false,
"space_guid": "d86ed364-39c3-4dbf-ac43-4600b6169a79",
"stack_guid": "32b714d0-f757-43c7-a26d-8b97c8980923",
"buildpack": null,
"detected_buildpack": "ruby 1.6.14",
"environment_json": {
},
"memory": 256,
"instances": 1,
"disk_quota": 1024,
"state": "STARTED",
"version": "62ce1b40-5268-4367-b525-d4113ab3723a",
"command": null,
"console": false,
"debug": null,
"staging_task_id": "9904ddbe1e904883a80f12eead29462a",
"package_state": "STAGED",
"health_check_type": "port",
"health_check_timeout": null,
"staging_failed_reason": null,
"staging_failed_description": null,
"diego": true,
"docker_image": null,
"package_updated_at": "2016-04-14T21:24:04Z",
"detected_start_command": "bundle exec rackup config.ru -p $PORT",
"enable_ssh": true,
"docker_credentials_json": {
"redacted_message": "[PRIVATE DATA HIDDEN]"
},
"ports": [
8080
],
"space_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79",
"space": {
"metadata": {
"guid": "d86ed364-39c3-4dbf-ac43-4600b6169a79",
"url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79",
"created_at": "2016-04-14T00:12:43Z",
"updated_at": null
},
"entity": {
"name": "s",
"organization_guid": "087da737-cd20-4e5b-833a-a19173ab99c9",
"space_quota_definition_guid": null,
"allow_ssh": true,
"organization_url": "/v2/organizations/087da737-cd20-4e5b-833a-a19173ab99c9",
"developers_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/developers",
"managers_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/managers",
"auditors_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/auditors",
"apps_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/apps",
"routes_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/routes",
"domains_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/domains",
"service_instances_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/service_instances",
"app_events_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/app_events",
"events_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/events",
"security_groups_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79/security_groups"
}
},
"stack_url": "/v2/stacks/32b714d0-f757-43c7-a26d-8b97c8980923",
"stack": {
"metadata": {
"guid": "32b714d0-f757-43c7-a26d-8b97c8980923",
"url": "/v2/stacks/32b714d0-f757-43c7-a26d-8b97c8980923",
"created_at": "2016-04-13T17:35:38Z",
"updated_at": null
},
"entity": {
"name": "cflinuxfs2",
"description": "Cloud Foundry Linux-based filesystem"
}
},
"routes_url": "/v2/apps/4a0ebffe-8733-4dee-837e-0bdf7af939cb/routes",
"routes": [
{
"metadata": {
"guid": "83166879-27f3-4e49-a0c7-823256d26594",
"url": "/v2/routes/83166879-27f3-4e49-a0c7-823256d26594",
"created_at": "2016-04-14T00:12:56Z",
"updated_at": null
},
"entity": {
"host": "dora",
"path": "",
"domain_guid": "a1a51256-8740-400b-be55-f5dddde7e1c3",
"space_guid": "d86ed364-39c3-4dbf-ac43-4600b6169a79",
"service_instance_guid": null,
"port": 0,
"domain_url": "/v2/domains/a1a51256-8740-400b-be55-f5dddde7e1c3",
"space_url": "/v2/spaces/d86ed364-39c3-4dbf-ac43-4600b6169a79",
"apps_url": "/v2/routes/83166879-27f3-4e49-a0c7-823256d26594/apps",
"route_mappings_url": "/v2/routes/83166879-27f3-4e49-a0c7-823256d26594/route_mappings"
}
}
],
"events_url": "/v2/apps/4a0ebffe-8733-4dee-837e-0bdf7af939cb/events",
"service_bindings_url": "/v2/apps/4a0ebffe-8733-4dee-837e-0bdf7af939cb/service_bindings",
"service_bindings": [
],
"route_mappings_url": "/v2/apps/4a0ebffe-8733-4dee-837e-0bdf7af939cb/route_mappings"
}
}
]
}
REQUEST: [2016-04-15T15:33:59-07:00]
GET /v2/info HTTP/1.1
Host: api.runtime1.cf-app.com
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: go-cli 6.17.0+5d0be0a / darwin
RESPONSE: [2016-04-15T15:33:59-07:00]
HTTP/1.1 200 OK
Content-Length: 604
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Date: Fri, 15 Apr 2016 22:33:59 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Vcap-Request-Id: a6541b40-7ecb-45ed-67ed-ce7165e27130
X-Vcap-Request-Id: 45a11716-2bc6-4408-47d4-eb5249345bcc::0c7ad5b1-8d2d-4a54-ac8b-9f32504702c0
{"name":"","build":"","support":"","version":0,"description":"","authorization_endpoint":"https://login.runtime1.cf-app.com","token_endpoint":"https://uaa.runtime1.cf-app.com","min_cli_version":null,"min_recommended_cli_version":null,"api_version":"2.52.0","app_ssh_endpoint":"ssh.runtime1.cf-app.com:2222","app_ssh_host_key_fingerprint":"SHA256:L65g5nDhDE1IUDI6u0GyVfMhcC1x6wmc3tTgQslLVFk","app_ssh_oauth_client":"ssh-proxy","logging_endpoint":"wss://loggregator.runtime1.cf-app.com:4443","doppler_logging_endpoint":"wss://doppler.runtime1.cf-app.com:4443","user":"75699580-0b60-45e1-80f6-11b0c01ff9cb"}
REQUEST: [2016-04-15T15:33:59-07:00]
GET /v2/info HTTP/1.1
Host: api.runtime1.cf-app.com
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: go-cli 6.17.0+5d0be0a / darwin
RESPONSE: [2016-04-15T15:34:00-07:00]
HTTP/1.1 200 OK
Content-Length: 604
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Date: Fri, 15 Apr 2016 22:33:59 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Vcap-Request-Id: 4bf0ea01-f826-4f23-74fe-614a485aaf92
X-Vcap-Request-Id: 176441cf-4533-485e-5538-21d41c9999de::a8e12082-e224-4996-b3e3-e25cb7ca059a
{"name":"","build":"","support":"","version":0,"description":"","authorization_endpoint":"https://login.runtime1.cf-app.com","token_endpoint":"https://uaa.runtime1.cf-app.com","min_cli_version":null,"min_recommended_cli_version":null,"api_version":"2.52.0","app_ssh_endpoint":"ssh.runtime1.cf-app.com:2222","app_ssh_host_key_fingerprint":"SHA256:L65g5nDhDE1IUDI6u0GyVfMhcC1x6wmc3tTgQslLVFk","app_ssh_oauth_client":"ssh-proxy","logging_endpoint":"wss://loggregator.runtime1.cf-app.com:4443","doppler_logging_endpoint":"wss://doppler.runtime1.cf-app.com:4443","user":"75699580-0b60-45e1-80f6-11b0c01ff9cb"}
REQUEST: [2016-04-15T15:34:00-07:00]
POST /oauth/token HTTP/1.1
Host: login.runtime1.cf-app.com
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/x-www-form-urlencoded
User-Agent: go-cli 6.17.0+5d0be0a / darwin
grant_type=refresh_token&refresh_token=eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJlYWU5ZGQwMy02NDAyLTQ5MWYtOWJiYS0zMTQyYTgzZDBhNGMtciIsInN1YiI6Ijc1Njk5NTgwLTBiNjAtNDVlMS04MGY2LTExYjBjMDFmZjljYiIsInNjb3BlIjpbIm9wZW5pZCIsInVhYS51c2VyIiwiY2xvdWRfY29udHJvbGxlci5yZWFkIiwicGFzc3dvcmQud3JpdGUiLCJjbG91ZF9jb250cm9sbGVyLndyaXRlIl0sImlhdCI6MTQ2MDc0MzU1NiwiZXhwIjoxNDYzMzM1NTU2LCJjaWQiOiJjZiIsImNsaWVudF9pZCI6ImNmIiwiaXNzIjoiaHR0cHM6Ly91YWEucnVudGltZTEuY2YtYXBwLmNvbS9vYXV0aC90b2tlbiIsInppZCI6InVhYSIsImdyYW50X3R5cGUiOiJwYXNzd29yZCIsInVzZXJfbmFtZSI6ImppbSIsIm9yaWdpbiI6InVhYSIsInVzZXJfaWQiOiI3NTY5OTU4MC0wYjYwLTQ1ZTEtODBmNi0xMWIwYzAxZmY5Y2IiLCJyZXZfc2lnIjoiYzY5ZWUyMzQiLCJhdWQiOlsiY2YiLCJvcGVuaWQiLCJ1YWEiLCJjbG91ZF9jb250cm9sbGVyIiwicGFzc3dvcmQiXX0.oWdGAgAidwZR0p80UMXpmJO0gffj9w7AM1FFS4VbXTsu08_VKtOj4eey-RsXj5L9QXPLOXMaTXPczRTZ4UyIS71sN9EnMzAbVJ_wlvu3HKOxMC0NFDsZjMDG5p0MfUwMz_048d9mN8ubgLDboRb-B36chfAwxBL3vTxZFf1mZGw&scope=
RESPONSE: [2016-04-15T15:34:00-07:00]
HTTP/1.1 200 OK
Content-Length: 1959
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Cache-Control: no-store
Connection: keep-alive
Content-Type: application/json;charset=UTF-8
Date: Fri, 15 Apr 2016 22:34:00 GMT
Expires: 0
Pragma: no-cache
Pragma: no-cache
Server: Apache-Coyote/1.1
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Vcap-Request-Id: a500f313-73c3-4cea-663b-3afc63816c0a
X-Xss-Protection: 1; mode=block
{"access_token":"[PRIVATE DATA HIDDEN]","token_type":"bearer","refresh_token":"[PRIVATE DATA HIDDEN]","expires_in":599,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"3c14d781-a9c3-4c26-aebc-e6d685b4e049"}
REQUEST: [2016-04-15T15:34:00-07:00]
GET /login?code=3xVgNz HTTP/0.0
Host: uaa.runtime1.cf-app.com
Referer: https://uaa.runtime1.cf-app.com/oauth/authorize?client_id=ssh-proxy&grant_type=authorization_code&response_type=code
RESPONSE: [2016-04-15T15:34:00-07:00]
HTTP/1.1 302 Found
Connection: close
Cache-Control: no-store
Content-Language: en-US
Date: Fri, 15 Apr 2016 22:34:00 GMT
Expires: 0
Location: https://uaa.runtime1.cf-app.com/login?code=3xVgNz
Pragma:
Server: Apache-Coyote/1.1
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Vcap-Request-Id: 4fdf36cd-9f74-407c-481b-c513e2886760
X-Xss-Protection: 1; mode=block
Content-Length: 0
FAILED
Error opening SSH connection: ssh: handshake failed: Unsupported host key fingerprint format
Platform Details
e.g. Mac OS X 10.11.3 (15D21) 64 bit
Shell
iTerm2 Build 2.9.20160102
We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/117741939.
Hi @APShirley
Thanks, we'll look at adding support for SHA256 fingerprints.
Regards, Dies Koper CF CLI PM
We did some followup investigation. The environment where this was initially configured had a bit of unusual (and potentially "unsupported" though it's interesting that it worked fine with non-cf ssh) configuration. The host_key_fingerprint was specified in the cf deployment thus:
app_ssh:
oauth_client_id: ssh-proxy
host_key_fingerprint: SHA256:L65g5nDhDE1IUDI6u0GyVfMhcC1x6wmc3tTgQslLVFk
We believe this is the SHA256 fingerprint for the value configured in the diego deployment as diego.ssh_proxy.host_key.
Public key verification flow
We provide a public key fingerprint to the cloud controller job in the CF manifest. This fingerprint is echoed to the CLI codebase when we run cf ssh (it grabs it from /v2/info), and is checked against the fingerprint generated from the public key on the diego ssh proxy.
Potential issue
We were able to find documentation provided by diego on how to generate the md5 version of the public key fingerprint.
It might be hard to find this documentation when looking at the Cloud Foundry documentation as a whole. From the documentation they make it pretty clear that they only "support" md5 fingerprints.
The Release Integration team wasn't sure how they ever ended up with a manifest with that particular sha256 fingerprint, but by virtue of them ending up with a sha256 fingerprint it's obvious they didn't use the documentation we just listed. Does this point to an issue with the discoverability of this documentation?
Product Question: Should we support hashing algorithms beyond md5?
The choice of hash algorithm when generating the public key fingerprint is not a safety/security issue: the hash exists only to turn a "large" public key into a "smaller" more readable string, which md5 is fine for. Because using an md5 fingerprint is sufficient for our use, and it's already documented, it raises the question of why we need to support verifying the public key using any other hash algorithm. Can we just document how to generate this via md5 and then remove the code for sha1 hashing, and close this issue for sha256 hashing?
Follow-on with CAPI: Can we remove app_ssh.host_key_fingerprint altogether?
This needs to be discussed with @SocalNick, but can we instead move to using the full public key?
This would mean that we would provide something like:
app_ssh:
host_public_key: AAAAB3NzaC1yc2EAAAADAQABAAABAQC188vaje9qH/XCQD3g+nk/15dhhI/FqI416fFHfHChGpdYEb+Dh3Wxo6nBz/QIzpnlDDpoP/6GuvfllV4eGA3kW6YX8j8Y7I3kB4qbAUC44CnchsOtg5qymDG2KI3ZHhACawmRbeUz2eRtkzQ2Ye5IcIwAvZUbkDHRzzzt7RtcWk6f/Fretypo++H7fwNaK8TeDlXAuLwW87fo/H7mVsk8AguIF3P2LU+r0URfByIW0xiwxRdDqodOhOvTN+2upUyw/FEkrKwhiqEyhDDObjYrzOI/1iIWCqCkYCuFTfCrPQTD8/vP+ksizwt3gDKUuqMHHwvAOvKaree9JhBIkfAv
And then /v2/info would provide back
{
...
"app_ssh_host_public_key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQC188vaje9qH/XCQD3g+nk/15dhhI/FqI416fFHfHChGpdYEb+Dh3Wxo6nBz/QIzpnlDDpoP/6GuvfllV4eGA3kW6YX8j8Y7I3kB4qbAUC44CnchsOtg5qymDG2KI3ZHhACawmRbeUz2eRtkzQ2Ye5IcIwAvZUbkDHRzzzt7RtcWk6f/Fretypo++H7fwNaK8TeDlXAuLwW87fo/H7mVsk8AguIF3P2LU+r0URfByIW0xiwxRdDqodOhOvTN+2upUyw/FEkrKwhiqEyhDDObjYrzOI/1iIWCqCkYCuFTfCrPQTD8/vP+ksizwt3gDKUuqMHHwvAOvKaree9JhBIkfAv",
...
}
We can then either directly compare that to the public key, or choose our own "fingerprinting algorithm". We would then change the documentation to show people how to extract the public key from their public key file.
Doesn't really feel like anything is broken here, just a matter of documenting this in the correct location. @APShirley can your team own improving the docs for setting SSH for Cloud Foundry apps?
@APShirley It's not entirely clear to me whether the issue here is simply the lack of documentation led you to running a command that gave you a SHA256 fingerprint, so improved documentation for using an md5 version of the fingerprint would resolve the issue, or whether this is a feature enhancement request for accepting SHA256 fingerprints. Can you clarify?
I'm not a security expert, but it seems although ssh-keygen may default to SHA256 fingerprints, MD5 is still common for distributing fingerprints, and if we are going to make an enhancement, @nickwei84 proposed an interesting alternative that sounds more lasting.
Closing while waiting for more feedback.
This is probably not a CLI issue. If the CLI were to support SHA256 fingerprints for this, it would be extending support explicitly disavowed by the Diego team.
There might be improvements to be had in the documentation or configuration pattern for the CC in connection to Diego.
I suspect we're using the fingerprint in v2/info to keep the output of that endpoint readable. It's one of the few that humans directly use.
@kimahoff - could you support this cross-team documentation improvement effort?