大网数据广告活动
服务器运维问答

apt-get maddeningly doesn't work with tsocks proxy set up with ssh

· 52CE 我爱测

I have a machine that cannot access the internet, yet can connect to a machine that does. I don't want to use a proxy server, I've been told that I can just use ssh. So I've proceeded simply by ssh -D 1080 [email omitted] I've co…

问题原文

原帖链接 · user335886 · CC BY-SA 3.0

I have a machine that cannot access the internet, yet can connect to a machine that does. I don't want to use a proxy server, I've been told that I can just use ssh. So I've proceeded simply by

ssh -D 1080 [email omitted]

I've confirmed that this works by doing

curl -v --socks5-hostname localhost:1080 http://google.com

This command returns expected HTML so it must be working.

I have changed my /etc/tsocks.conf to simply read:

server = 127.0.0.1
server_port = 1080

However, apt-get is having none of it;

# tsocks apt-get update
Err http://security.debian.org wheezy/updates Release.gpg
Could not resolve 'security.debian.org'
etc

My /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

I've been googling for a while, I tried adding the following to /etc/apt/apt.conf

Acquire::http::Proxy "http://localhost:1080/";

and not using tsocks at all, (I've tried it both ways), this makes it fail even faster.

I'm out of ideas, this should really work but doesn't. Any help?

已采纳解答

原帖链接 · user335886 · CC BY-SA 3.0

The problem was with DNS.

Apparently, tsocks can't or won't resolve domain names.

I added to /etc/hosts the IP addresses of each of the domain names apt-get was trying to look for and tsocks magically worked.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。