我有一个VCenter Server版本5.5。我正在尝试使用以下命令生成会话ID以对ReST API请求进行身份验证:
curl -kv -X POST -H 'Accept: application/json' --basic -u me@abc.co.in:myPass! $VCENTER/rest/com/vmware/cis/session
其中$ VCENTER = https://vc
这是我得到的输出
* Hostname was NOT found in DNS cache
* Trying 1.2.3.4...
* Connected to vc (1.2.3.4) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
* subject: O=VMware, Inc.; OU=vCenterServer_2014.12.24_203443; CN=VMware default certificate; emailAddress=support@vmware.com
* start date: 2014-12-24 04:44:30 GMT
* expire date: 2024-12-22 04:44:32 GMT
* issuer: O=VMware, Inc.; OU=vCenterServer_2014.12.24_203443; CN=VC.xyz.co.in; emailAddress=support@vmware.com
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Basic with user 'me@xyz.co.in'
> POST /rest/com/vmware/cis/session HTTP/1.1
> Authorization: Basic YWthbmtzaGFfamFpbkBwZXJzaXN0ZW50LmNvLmluOmFra2FTZXAyMDE3IQ==
> User-Agent: curl/7.35.0
> Host: pt-vc
> Accept: application/json
>
< HTTP/1.1 400 Bad Request
< Date: Thu, 13 Jul 2017 09:33:40 GMT
< Connection: close
< Content-Type: text; charset=plain
< Content-Length: 0
<
* Closing connection 0
* SSLv3, TLS alert, Client hello (1):
看看输出我不知道出了什么问题以及在哪里。这是因为我的密码有!
,需要将其转换为十六进制等效值吗?
答案 0 :(得分:2)
感叹号应该可以作为密码传递。
问题可能是由于vCenter 5.5没有任何RESTful端点可用。这是在vSphere / vCenter 6.0中引入的。
如果您使用的是6.0或6.5环境,那么您的输出将更接近以下内容:
curl -kv -X POST -H 'Accept: application/json' --basic -u user@domain.lab:VMware1! https://vcsa01.domain.lab/rest/com/vmware/cis/session
* Trying 10.159.13.52...
* Connected to vcsa01.domain.lab (10.159.13.52) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: VCSA01
* Server auth using Basic with user 'user@domain.lab'
> POST /rest/com/vmware/cis/session HTTP/1.1
> Host: vcsa01.domain.lab
> Authorization: Basic ZWNrQGNwYnUubGFiOlZNd2FyZTEh
> User-Agent: curl/7.43.0
> Accept: application/json
>
< HTTP/1.1 200 OK
< Date: Thu, 13 Jul 2017 18:47:18 GMT
< Set-Cookie: vmware-api-session-id=37e6921e6a3905b47ba356aaad19d3d6;Path=/rest;Secure;HttpOnly
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
<
* Connection #0 to host vcsa01.domain.lab left intact
{"value":"37e6921e6a3905b47ba356aaad19d3d6"}