【问题标题】:Cannot download with Curl and Wget in AWS EC2 Linux server无法在 AWS EC2 Linux 服务器中使用 Curl 和 Wget 下载
【发布时间】:2022-06-13 15:40:13
【问题描述】:

我正在使用带有 Putty 的 EC2 服务器。

我想将最新的声纳扫描仪下载到 EC2 服务器。

我尝试使用 Wget 和 Curl 访问下载 URL,但它们总是失败并显示相同的消息。

这是我使用的服务器系统:Red Hat Enterprise Linux Server 7.8 (Maipo)

  • WGET
GNU Wget 1.14 built on linux-gnu.
[root@ip-10-X-X-X ~]# wget -v https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
--2022-06-09 09:56:55--  https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
Resolving binaries.sonarsource.com (binaries.sonarsource.com)... 99.84.191.23, 99.84.191.71, 99.84.191.75, ...
Connecting to binaries.sonarsource.com (binaries.sonarsource.com)|99.84.191.23|:443... connected.
Unable to establish SSL connection.
  • 卷曲
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.44 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
[root@ip-10-X-X-X ~]# curl -O -v https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to binaries.sonarsource.com port 443 (#0)
*   Trying 99.84.208.28...
* Connected to binaries.sonarsource.com (99.84.208.28) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
  0     0    0     0    0     0      0      0 --:--:--  0:00:29 --:--:--     0* NSS error -5938 (PR_END_OF_FILE_ERROR)
* Encountered end of file
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0
* Closing connection 0
curl: (35) Encountered end of file

我是使用此 EC2 服务器的新手。你知道我能做些什么来解决这个问题吗?

谢谢你,任何帮助将不胜感激!

编辑:

  • 我分别在 curl 和 wget 中添加了 -k--no-check-certificate,但仍然返回相同的错误消息
  • 我尝试check the wget connection,但它似乎不适用于具有下载端点的 URL:
[root@ip-10-70-10-87 settings]# wget -q --spider https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
[root@ip-10-70-10-87 settings]# echo $?
4
[root@ip-10-70-10-87 settings]# wget -q --spider https://www.google.com/
[root@ip-10-70-10-87 settings]# echo $?
0
[root@ip-10-70-10-87 settings]# wget -q --spider https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
[root@ip-10-70-10-87 settings]# echo $?
4
[root@ip-10-70-10-87 settings]# wget -q --spider https://assets.ctfassets.net/br4ichkdqihc/6jNPyoUDznu06Mk4dr9CEn/560e34fec221fad43a501442a551ad92/SimpliSafe_Outdoor_Battery_Camera_Open_Source_Disclosures_Launch.DOCX
[root@ip-10-70-10-87 settings]# echo $?
4
[root@ip-10-70-10-87 settings]# wget -q --spider https://twitter.com/home
[root@ip-10-70-10-87 settings]# echo $?
0

【问题讨论】:

  • 一种变通方法是使用带有 curl 的 -k 标志或带有 wget 的 --no-check-certificate。这不是解决方案!
  • 您是否更新了 EC2 上的操作系统?您的 SSL 信息似乎是旧的或坏的。
  • 首先尝试更新openssl 包,但我认为您的CA 证书可能会以某种方式损坏。尝试按照本指南重置您的受信任 CA 证书列表 - access.redhat.com/solutions/1549003
  • 嗨@Riz,我已经尝试将-k--no-check-certificate 添加到curl 和wget,但仍然返回提到的相同错误消息
  • @stdunbar 如何确保我的操作系统是最新的?我确定管理员每月都会修补操作系统,但我只是想确保..

标签: linux amazon-web-services curl amazon-ec2 wget


【解决方案1】:

您是否尝试过更新操作系统并尝试使用不带 -v 标志的 wget 命令,如下所示:

wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zi

也可以添加--no-check-certificate或者修改~/.wgetrc文件添加

check_certificate = off

如果你信任主机,你可以做这两件事,希望这会有所帮助

【讨论】:

  • 嗨@TaylorBlackburn-292。首先,我如何知道我的操作系统是否是最新的?我很确定服务器每月都会由管理员对操作系统进行修补,但我只是想确保..为了在 wget 期间删除 -v,不,它仍然无法使用与提到的相同的错误消息。添加--no-check-certificate 也仍然返回Unable to establish SSL connection. 的错误消息
【解决方案2】:

如果你不是root用户,下载前需要在命令中添加sudo 尝试使用此命令并下载 "sudo wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778.zip"

【讨论】:

  • 嘿 Sriranga,我认为这是一个 https 证书问题,而不是用户权限问题。基于“无法建立 SSL 连接”
  • 嗨@Sriranga,在执行 wget/curl 之前,我已经以 root 用户身份登录,如描述中所述
猜你喜欢
  • 2022-06-11
  • 1970-01-01
  • 2021-06-11
  • 1970-01-01
  • 1970-01-01
  • 2011-05-04
  • 2012-03-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多