最近买了一个云耀云服务器,使用SSH 登录Linux服务器,使用sudo apt-get update出现如下错误:
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
Err:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
Err:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
Err:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
解决方法
参考之前写的文章 ubuntu下sudo apt-get update Sources 404 Not Found [IP: 91.189.92.200 80]解决办法
修改 etc/apt/sources.list:
//备份源文件
sudo cp -rfv /etc/apt/sources.list /etc/apt/sources.list.back
//编辑source.list文件
sudo vi /etc/apt/sources.list
全选快捷键:shift+v选中一行,shift+g调到结尾实现全选
删除所选择的内容:dd
按 i 进入插入模式,复制如下内容:
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
注意删除文件结尾不必要的文字,按 esc 键,再:wq 保存退出
此时再次执行sudo apt-get update,已经可以正常运行了,速度飞快~
Ign:1 http://mirrors.163.com/ubuntu trusty InRelease
Get:2 http://mirrors.163.com/ubuntu trusty-security InRelease [65.9 kB]
Get:3 http://mirrors.163.com/ubuntu trusty-updates InRelease [65.9 kB]
Get:4 http://mirrors.163.com/ubuntu trusty-proposed InRelease [65.9 kB]
Get:5 http://mirrors.163.com/ubuntu trusty-backports InRelease [65.9 kB]
Get:6 http://mirrors.163.com/ubuntu trusty Release [58.5 kB]
Get:7 http://mirrors.163.com/ubuntu trusty-security/restricted Sources [4,931 B]
Get:8 http://mirrors.163.com/ubuntu trusty-security/main Sources [172 kB]
Get:75 http://mirrors.163.com/ubuntu trusty/multiverse i386 Packages [134 kB]
Fetched 30.9 MB in 8s (3,670 kB/s)
Reading package lists... Done
至此,问题已经解决
备注:如果出现The following signatures couldn’t be verified because the public key is not available,请参考如下解决:
出错信息:
Ign:1 http://extras.ubuntu.com/ubuntu trusty InRelease
Get:2 http://extras.ubuntu.com/ubuntu trusty Release [11.9 kB]
Get:3 http://extras.ubuntu.com/ubuntu trusty Release.gpg [72 B]
Ign:3 http://extras.ubuntu.com/ubuntu trusty Release.gpg
Err:4 http://cn.archive.ubuntu.com/ubuntu trusty InRelease
Cannot initiate the connection to cn.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to cn.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Could not connect to cn.archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to cn.archive.ubuntu.com:80 (91.189.91.38), connection timed out
Err:5 http://cz.archive.ubuntu.com/ubuntu trusty-updates InRelease
Cannot initiate the connection to cz.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to cz.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to cz.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to cz.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Could not connect to cz.archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to cz.archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to cz.archive.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to cz.archive.ubuntu.com:80 (91.189.88.152), connection timed out
Reading package lists... Done
W: GPG error: http://extras.ubuntu.com/ubuntu trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192
E: The repository 'http://extras.ubuntu.com/ubuntu trusty Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
执行如下命令:
//注意如下两句命令中的16126D3A3E5C1192需要替换为控制台中实际显示的值
sudo gpg --keyserver keyserver.ubuntu.com --recv 16126D3A3E5C1192
sudo gpg --export --armor 16126D3A3E5C1192 | sudo apt-key add -