Tag: ssh

Net-ssh会话超时

我正在使用Net-ssh来启动远程Python脚本。 当Python脚本需要很长时间(大约20分钟)时,Ruby脚本似乎挂起并且永远不会完成。 我已经通过直接运行脚本来测试脚本,它完成没有任何错误。 当脚本在较短的时间内执行时,一切正常。 这是我正在使用的代码的摘录: (0..(@number_of_vms – 1)).each_with_index do |vm, i| threads << Thread.new do Net::SSH.start('ip-address-vm', user, options = …) do |session| cmd = 'python python_script.py' output = session.exec!(cmd) end end end threads.each {|thr| thr.join } 这可能与ssh会话的某种超时有关吗? 编辑:我已validation脚本已在远程服务器上成功完成。

Ruby Net :: SSH使用变量插值更改目录

我对Ruby很新,所以如果我遗漏了一些明显的东西,请原谅我。 问题是Ruby似乎没有在Net :: SSH.exec中进行变量插值! 方法。 VCL_DIR = “/usr/local/etc/varnish/” host = ‘0.0.0.0’ Net::SSH.start(host, ‘root’) do |ssh| puts “Changing directories to #{VCL_DIR}” ssh.exec!(“cd #{VCL_DIR}”) res = ssh.exec!(“pwd”) puts “Server reports current directory as #{res}” end 输出: Changing directories to /usr/local/etc/varnish/ Server reports current directory as /root 任何帮助表示赞赏。 使用Ruby 1.9.3p194

Capistrano错误:无法连接到ssh-agent

我正在使用带有Capistrano部署的Bedrock。 当我使用命令bundle exec cap staging deploy:check我收到了身份validation错误: … D, [2015-05-09T15:39:53.878464 #15636] DEBUG — net.ssh.authentication.session[1e34a58]: trying publickey D, [2015-05-09T15:39:53.878464 #15636] DEBUG — net.ssh.authentication.agent[1e30d2c]: connecting to ssh-agent E, [2015-05-09T15:39:53.879447 #15636] ERROR — net.ssh.authentication.agent[1e30d2c]: could not connect to ssh-agent E, [2015-05-09T15:39:53.879447 #15636] ERROR — net.ssh.authentication.session[1e34a58]: all authorization methods failed (tried publickey) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as deploy@SERVER_IP: […]

ssh远程服务器登录脚本

目前我正在尝试使用“pty”和“expect”ruby库编写一个ruby脚本来登录SSH远程服务器。 并尝试使用该脚本在远程系统内创建新的rails应用程序。 任何人都可以告诉我。 如何使用ruby库登录到远程服务器?

Ruby Net:SSH控制大师?

我目前有一个Ruby(Rails)应用程序,需要进行大量的短SSH连接。 这可以使用Ruby Net :: SSH库正常工作,除了应用程序每次我想要发出命令时都必须登录并协商密钥,这太慢了。 有没有办法用Ruby Net :: SSH启用Control Master? 在命令行测试中,这使得登录(在第一个之后)非常快,因为连接已经打开(密钥被协商等)。 如果Net :: SSH无法做到这一点,那么有人可以建议一个可以做到的替代库吗? 我想这必须是一个共同的要求,所以希望有人可以提供帮助。 谢谢!

使用ruby Net :: SSH通过sudo读取远程文件

我必须读取一个远程文件的内容,我有权使用cat,less或tail读取(sudo)。 我将在Ruby中执行此操作,因此我假设我应该使用Net :: SSH来执行此操作。 该文件是一个日志文件,因此它可能非常大。 这是我现在正在尝试的代码: require ‘rubygems’ require ‘net/ssh’ cmd = “sudo cat /var/logs/httpd/ACCESS_log.2012.03.23” Net::SSH.start( “SERVER” , “USER”, :password => “PASSWORD”) do |ssh| ssh.open_channel do |channel| channel.request_pty channel.exec(cmd); channel.on_close do puts “shell terminated” end channel.on_eof do |ch| puts “remote end is done sending data” end channel.on_extended_data do |ch, type, data| puts “got stderr: #{data.inspect}” […]

如何SSH交互式会话

今天是个好日子 我需要在linux机器上执行命令这个命令是交互式命令。 交互式命令意味着需要输入[yes,no]或两次密码 我的真实案例是。 我创建了一个脚本执行命令并成功获取输出。 但有些服务器的登录密码已过期,所以我需要与服务器进行交互才能发送当前密码+新密码(两次) ssh userName@10.0.0.243 userName@10.0.0.243’s password: You are required to change your password immediately (password aged) Last login: Sun Aug 7 13:15:40 2011 from 10.0.0.28 WARNING: Your password has expired. You must change your password now and login again! Changing password for user userName. Changing password for userName (current) UNIX password: […]

ruby net-ssh登录shell

有什么办法可以使用net-ssh在ruby中获取登录shell吗? 这有可能吗? 通过登录shell我的意思是源/ etc / profile ..

Openshift端口转发

已经有很多关于它的主题。 但是我被困住了 我成功配置了ssh! 现在我想配置portforwarding与TOAD连接。 我使用了这个tut: https : //blog.openshift.com/getting-started-with-port-forwarding-on-openshift/ 现在当我尝试rhc port-forward -a php时 我得到这个错误无法解析PKey:没有起始行 我创建了这个: http : //blog.skypayjm.com/2015/02/accessing-remote-openshifts-database.html 我试图降级ssh,但它没有改变任何东西。 有人知道我做错了什么吗? 真诚的,布莱希特

Capistrano,防火墙和隧道

我们正在使用Capistrano自动将新版本的PHP应用程序推送到生产服务器。 生产服务器(我们称之为生产)是公共的,而我们的存储库服务器(我们称之为repo)与我们自己的机器一起位于我们的公司防火墙后面。 默认配置的Capistrano将无法工作,因为生产无法与回购交谈。 我想知道是否有某种程度上我可以将capistrano设置为SSH以首先进行回购,然后通过SSH连接到生产,在端口上打开一个隧道,然后我可以使用它从生产回SSH到repo以从SCM获取更改。 我无法弄清楚如何设置或找出更好的解决方案。 想法? 编辑: 我试过这个: role :web, “deploy.com” namespace :deploy do task :remote_tunnel do run ‘Creating SSH tunnel…’ do |channel, stream, data| ssh = channel.connection ssh.forward.remote(22, ‘server.com’, 10000, ‘127.0.0.1’) ssh.loop {!ssh.forward.active_remotes.include?([10000, ‘127.0.0.1’])} end end end before “deploy:update_code”, “deploy:remote_tunnel” 但我一直收到这个错误: failed: “sh -c ‘Creating SSH tunnel…'” on deploy.com