如何从代理 (ISA-NTLM) 后面更新 Ruby Gems

发布于 2024-07-24 09:36:03 字数 187 浏览 8 评论 0原文

我后面的防火墙正在仅 NTLM 模式下运行 Microsoft ISA 服务器。 是否有人成功通过 Ruby SSPI gem 或其他方法安装/更新了 Ruby gem?

……或者我只是懒惰?

注意:rubysspi-1.2.4 不起作用。

这也适用于“igem”,IronRuby 项目的一部分

The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?

... or am I just being lazy?

Note: rubysspi-1.2.4 does not work.

This also works for "igem", part of the IronRuby project

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(20

空名 2024-07-31 09:36:03

对于 Windows 操作系统,我使用 Fiddler 来解决该问题。

  1. 从 www.fiddler2.com 安装/运行 Fiddler
  2. 运行 gem:

    $ gem install --http-proxy http://localhost:8888 $gem_name 
      

For the Windows OS, I used Fiddler to work around the issue.

  1. Install/Run Fiddler from www.fiddler2.com
  2. Run gem:

    $ gem install --http-proxy http://localhost:8888 $gem_name
    
╰つ倒转 2024-07-31 09:36:03

我无法通过命令行开关让我的工作正常工作,但我只需通过设置我的 HTTP_PROXY 环境变量就可以做到这一点。 (请注意,大小写似乎很重要)。 我有一个批处理文件,其中有这样一行:

SET HTTP_PROXY=http://%USER%:%PASSWORD%@%SERVER%:%PORT%

显然,在到达这一行之前,我设置了四个引用的变量。 举个例子,如果我的用户名是“wolfbyte”,我的密码是“secret”,我的代理称为“pigsy”并在端口 8080 上运行:

SET HTTP_PROXY=http://wolfbyte:secret@pigsy:8080

您可能需要小心管理方式,因为它将您的密码以纯文本形式存储在机器的会话,但我认为这不应该是一个太大的问题。

I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my HTTP_PROXY environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:

SET HTTP_PROXY=http://%USER%:%PASSWORD%@%SERVER%:%PORT%

I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:

SET HTTP_PROXY=http://wolfbyte:secret@pigsy:8080

You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.

流心雨 2024-07-31 09:36:03

这完全有效:

gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name

This totally worked:

gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name
信愁 2024-07-31 09:36:03

我在工作中一直使用 cntlm (http://cntlm.sourceforge.net/)。 配置与 ntlmaps 非常相似。

效果很好,还允许我连接我的 Ubuntu 盒子到 ISA 代理。

查看 http://cntlm.wiki.sourceforge.net/ 了解更多信息

I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.

Works great, and also allows me to connect my Ubuntu box to the ISA proxy.

Check out http://cntlm.wiki.sourceforge.net/ for more information

梦忆晨望 2024-07-31 09:36:03

我尝试了其中一些解决方案,但没有一个有效。 我终于找到了一个适合我的解决方案:

gem install -p http://proxy_ip:proxy_port rails

使用 -p 参数来传递代理。 我使用的是 Gem 版本 1.9.1。

I tried some of these solutions, and none of them worked. I finally found a solution that works for me:

gem install -p http://proxy_ip:proxy_port rails

using the -p parameter to pass the proxy. I'm using Gem version 1.9.1.

零時差 2024-07-31 09:36:03

创建一个 .gemrc 文件(在 /etc/gemrc 或 ~/.gemrc 中,或者例如在 /opt/chef/embedded/etc/gemrc 中使用 Chef gem),其中包含:

http_proxy: http://proxy:3128

然后您可以 gem install 作为通常。

Create a .gemrc file (either in /etc/gemrc or ~/.gemrc or for example with chef gem in /opt/chef/embedded/etc/gemrc) containing:

http_proxy: http://proxy:3128

Then you can gem install as usual.

淡淡的优雅 2024-07-31 09:36:03

这完美地解决了我的问题:

gem install -p http://proxy_ip:proxy_port compass

您可能需要向其中添加您的用户名和密码:

gem install -p http://[username]:[password]@proxy_ip:proxy_port compass

This solved my problem perfectly:

gem install -p http://proxy_ip:proxy_port compass

You might need to add your user name and password to it:

gem install -p http://[username]:[password]@proxy_ip:proxy_port compass
祁梦 2024-07-31 09:36:03

如果您在通过代理进行身份验证时遇到问题,请务必按照以下格式设置环境变量:

set HTTP_PROXY=some.proxy.com
set HTTP_PROXY_USER=user
set HTTP_PROXY_PASS=password

user:password@ 语法似乎不起作用,而且还有一些命名错误的语法Stack Overflow 和各种论坛帖子上浮动的环境变量。

另请注意,您的宝石可能需要一段时间才能开始下载。 起初我以为它不起作用,但只要有一点耐心,他们就开始按预期下载。

If you are having problems getting authenticated through your proxy, be sure to set the environment variables in exactly the format below:

set HTTP_PROXY=some.proxy.com
set HTTP_PROXY_USER=user
set HTTP_PROXY_PASS=password

The user:password@ syntax doesn't seem to work and there are also some badly named environment variables floating around on Stack Overflow and various forum posts.

Also be aware that it can take a while for your gems to start downloading. At first I thought it wasn't working but with a bit of patience they started downloading as expected.

风铃鹿 2024-07-31 09:36:03

快速回答:添加带有安装/更新参数的代理配置

gem install --http-proxy http://host:port/ package_name

gem update --http-proxy http://host:port/ package_name

Quick answer : Add proxy configuration with parameter for both install/update

gem install --http-proxy http://host:port/ package_name

gem update --http-proxy http://host:port/ package_name
尘世孤行 2024-07-31 09:36:03

我尝试了上述所有解决方案,但没有一个有效。 如果您使用的是 Linux/macOS,我强烈建议您通过 ssh 隧道使用 tsocks。 为了让这个设置工作,你需要一台可以通过 ssh 登录的机器,此外还需要安装一个名为 tsocks 的程序。

这里的想法是通过 SSH(socks5 代理)创建动态隧道。 然后,我们配置 tsocks 以使用此隧道并启动我们的应用程序,在本例中:

tsocks gem install ...

或考虑 Rails 3.0:

tsocks bundle install

更详细的指南可以在以下位置找到:

http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel -and-tsocks-under-ubuntu/

尽管是为 Ubuntu 编写的,但该过程应该适用于所有基于 Unix 的计算机。 Windows 上 tsocks 的替代方案是 FreeCap (http://www.freecap.ru/eng/)。 Windows 上可行的 SSH 客户端称为 putty。

I tried all the above solutions, however none of them worked. If you're on linux/macOS i highly suggest using tsocks over an ssh tunnel. What you need in order to get this setup working is a machine where you can log in via ssh, and in addition to that a programm called tsocks installed.

The idea here is to create a dynamic tunnel via SSH (a socks5 proxy). We then configure tsocks to use this tunnel and to start our applications, in this case:

tsocks gem install ...

or to account for rails 3.0:

tsocks bundle install

A more detailed guide can be found under:

http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel-and-tsocks-under-ubuntu/

Despite being written for Ubuntu the procedure should be applicable for all Unix based machines. An alternative to tsocks for Windows is FreeCap (http://www.freecap.ru/eng/). A viable SSH client on windows is called putty.

帅冕 2024-07-31 09:36:03

关于这个主题的帖子比比皆是,为了帮助其他人节省尝试不同解决方案的时间,以下是我经过数小时修改后的最终结果。

目前互联网上的三种解决方案是:
红宝石
应用程序服务器
cntlm

ruby​​sspi 只能在 Windows 计算机上运行,​​据我所知,因为它依赖于 Win32Api 库。 因此,如果您在 Windows 机器上尝试通过代理运行,那么这就是适合您的解决方案。 如果您使用的是 Linux 发行版,那么您就不走运了。

apserver 似乎是一个死项目。 我见过的帖子中列出的链接指向 sourceforge 上的 404 页面。 我在 sourceforge 上搜索“apserver”没有返回任何内容。

我看到的 cntlm 的 sourceforge 链接重定向到 http://cntlm.awk.cz/,但是超时了。 在 sourceforge 上搜索会发现此链接,该链接确实有效: http://sourceforge.net/projects/cntlm/< /a>

下载并配置 cntlm 后,我成功地通过代理安装了 gem,所以这似乎是 Linux 发行版的最佳解决方案。

Posts abound regarding this topic, and to help others save hours of trying different solutions, here is the final result of my hours of tinkering.

The three solutions around the internet at the moment are:
rubysspi
apserver
cntlm

rubysspi only works from a Windows machine, AFAIK, as it relies on the Win32Api library. So if you are on a Windows box trying to run through a proxy, this is the solution for you. If you are on a Linux distro, you're out of luck.

apserver seems to be a dead project. The link listed in the posts I've seen lead to 404 page on sourceforge. I search for "apserver" on sourceforge returns nothing.

The sourceforge link for cntlm that I've seen redirects to http://cntlm.awk.cz/, but that times out. A search on sourceforge turns up this link, which does work: http://sourceforge.net/projects/cntlm/

After downloading and configuring cntlm I have managed to install a gem through the proxy, so this seems to be the best solution for Linux distros.

心凉 2024-07-31 09:36:03

解决方法是安装 http://web。在本地计算机上的 archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ 上,配置它并通过此代理运行 gems。

  • 安装:只需下载 apserver 097(而不是实验性的 098!)并解压。
  • 配置:编辑 server.cfg 文件并将 MS 代理的值放入 PARENT_PROXYPARENT_PROXY_PORT 中。 输入“域”和“用户”的值。 将 PASSWORD 留空(冒号后不输入任何内容)——启动时系统会提示您。
  • 运行 apserver: cd aps097; python main.py
  • 运行 Gems:gem install—http-proxy http://localhost:5865/library

A workaround is to install http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ on your local machine, configure it and run gems through this proxy.

  • Install: Just download apserver 097 (and not the experimental 098!) and unpack.
  • Configure: Edit the server.cfg file and put the values for your MS proxy in PARENT_PROXY and PARENT_PROXY_PORT. Enter the values for DOMAIN and USER. Leave PASSWORD blank (nothing after the colon) – you will be prompted when launching it.
  • Run apserver: cd aps097; python main.py
  • Run Gems: gem install—http-proxy http://localhost:5865/ library
疯狂的代价 2024-07-31 09:36:03

我在代理后面工作,刚刚通过直接从 http://rubygems.org 下载来安装 SASS。

然后我运行 sudo gem install [path/to/downloaded/gem/file]。 我不能说这适用于所有宝石,但它可能对某些人有帮助。

I am working behind a proxy and just installed SASS by downloading directly from http://rubygems.org.

I then ran sudo gem install [path/to/downloaded/gem/file]. I cannot say this will work for all gems, but it may help some people.

梦屿孤独相伴 2024-07-31 09:36:03

这在 Windows 环境中对我有用:

set HTTP_PROXY=http://server:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=userparssword
set HTTPS_PROXY=http://server:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=userpassword

我有一个包含这些行的批处理文件,我可以在需要时使用它来设置环境值。

就我而言,诀窍是 HTTPS_PROXY 设置。 如果没有它们,我总是会收到 407 代理身份验证错误。

This worked for me in a Windows box:

set HTTP_PROXY=http://server:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=userparssword
set HTTPS_PROXY=http://server:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=userpassword

I have a batch file with these lines that I use to set environment values when I need it.

The trick, in my case, was HTTPS_PROXY sets. Without them, I always got a 407 proxy authentication error.

小…红帽 2024-07-31 09:36:03

如果您使用的是 *nix 系统,请使用以下命令:

export http_proxy=http://${proxy.host}:${port}
export https_proxy=http://${proxy.host}:${port}

然后尝试:

gem install ${gem_name}

If you are on a *nix system, use this:

export http_proxy=http://${proxy.host}:${port}
export https_proxy=http://${proxy.host}:${port}

and then try:

gem install ${gem_name}
佼人 2024-07-31 09:36:03

rubysspi-1.3.1 在 Windows 7 上为我工作,使用此页面中的说明:

http:// /www.stuartellis.eu/articles/installing-ruby/

rubysspi-1.3.1 worked for me on Windows 7, using the instructions from this page:

http://www.stuartellis.eu/articles/installing-ruby/

花开半夏魅人心 2024-07-31 09:36:03

如果你想使用 SOCKS5 代理,你可以尝试 ruby​​gems-socksproxy https://github.com/gussan/rubygems -socksproxy

它适用于我的 OSX 10.9.3。

If you want to use SOCKS5 proxy, you may try rubygems-socksproxy https://github.com/gussan/rubygems-socksproxy.

It works for me on OSX 10.9.3.

寄人书 2024-07-31 09:36:03

如果使用代理,您可以导航至 Ruby downloads,单击“下载”,这将下载指定的update (或 Gem )到所需的位置。

接下来,通过 Ruby 命令行,使用以下命令导航到下载位置:pushd [directory]

例如:pushd D:\Setups

然后运行以下命令:gem安装[更新名称] --local

例如:gem install ruby​​gems-update --local

在 Windows 7 上使用 Ruby 更新版本 2.4.1 进行测试。

要检查,请使用以下命令:ruby -v

If behind a proxy, you can navigate to Ruby downloads, click on Download, which will download the specified update ( or Gem ) to a desired location.

Next, via Ruby command line, navigate to the downloaded location by using : pushd [directory]

eg : pushd D:\Setups

then run the following command: gem install [update name] --local

eg: gem install rubygems-update --local.

Tested on Windows 7 with Ruby update version 2.4.1.

To check use following command : ruby -v

套路撩心 2024-07-31 09:36:03

与其编辑批处理文件(您可能必须对其他 Ruby gem 执行此操作,例如 Bundler),最好只执行一次并正确执行此操作。

在 Windows 上,在我的公司代理后面,我所要做的就是将 HTTP_PROXY 环境变量添加到我的系统中。

  1. 开始-> 右键单击计算机-> 属性
  2. 选择“高级系统设置”
  3. 点击高级-> 环境变量
  4. 创建一个名为“HTTP_PROXY”的新系统变量,并将值设置为您的代理服务器
  5. 重新启动或注销并重新登录

根据您的身份验证要求,HTTP_PROXY值可以像以下一样简单:

http://proxy-server-name

或更复杂,如其他人指出的那样

http://username:password@proxy-server-name:port-number

Rather than editing batch files (which you may have to do for other Ruby gems, e.g. Bundler), it's probably better to do this once, and do it properly.

On Windows, behind my corporate proxy, all I had to do was add the HTTP_PROXY environment variable to my system.

  1. Start -> right click Computer -> Properties
  2. Choose "Advanced System Settings"
  3. Click Advanced -> Environment Variables
  4. Create a new System variable named "HTTP_PROXY", and set the Value to your proxy server
  5. Reboot or log out and back in again

Depending on your authentication requirements, the HTTP_PROXY value can be as simple as:

http://proxy-server-name

Or more complex as others have pointed out

http://username:password@proxy-server-name:port-number
梦中楼上月下 2024-07-31 09:36:03

对于任何使用 SSH 建立隧道的人; 您可以创建使用 SOCKS 代理的 gem 命令版本:

  1. 使用 gem installocksify 安装 socksify (您需要能够至少在没有代理的情况下执行此步骤)
  2. 复制现有的 gem exe

    cp $(命令哪个 gem) /usr/local/bin/proxy_gem 
      
  3. 在您最喜欢的编辑器中打开它,并将其添加到顶部(在 shebang 之后)

    需要“socksify” 
    
      如果 ENV['SOCKS_PROXY'] 
        需要“socksify” 
        主机,端口 = ENV['SOCKS_PROXY'].split(':') 
        TCPSocket.socks_server = 主机 ||   '本地主机' 
        TCPSocket.socks_port = port.to_i ||   1080 
      结尾 
      
  4. 设置您的隧道

    ssh -D 8123 -f -C -q -N user@proxy 
      
  5. 使用 proxy_gem 运行 gem 命令

    SOCKS_PROXY=localhost:8123 proxy_gem 推送 mygem 
      

for anyone tunnelling with SSH; you can create a version of the gem command that uses SOCKS proxy:

  1. Install socksify with gem install socksify (you'll need to be able to do this step without proxy, at least)
  2. Copy your existing gem exe

    cp $(command which gem) /usr/local/bin/proxy_gem
    
  3. Open it in your favourite editor and add this at the top (after the shebang)

    require 'socksify'
    
    if ENV['SOCKS_PROXY']
      require 'socksify'
      host, port = ENV['SOCKS_PROXY'].split(':')
      TCPSocket.socks_server = host || 'localhost'
      TCPSocket.socks_port = port.to_i || 1080
    end
    
  4. Set up your tunnel

    ssh -D 8123 -f -C -q -N user@proxy
    
  5. Run your gem command with proxy_gem

    SOCKS_PROXY=localhost:8123 proxy_gem push mygem
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文