[求助]使用ssh连接远程unix服务器怎么运行sudo suusername命令?
ruby吧
全部回复
仅看楼主
level 1
littles0907 楼主
rname命令?[问题点数:50分]
    *
    * littles0907
    * (littles0907)
    *
    * 等 级:
    * 结帖率:100.00%
    *
楼主发表于:2009-08-11 11:14:14
Net::SSH.start('host', 'usr', :password => 'psswd') do |ssh|
channel = ssh.open_channel do |ch|
      ch.exec "sudo suroot" do |ch, success|
  raise "could not execute command" unless success
  ch.on_data do |c, data|
    puts data
  end
  ch.on_extended_data do |c, type, data|
          puts data
        end
      ch.on_close { puts "done" }
      end
end
end
输出结果
        #################################################################
        # #
        # This system is for the use of authorized users only. #
        # Individuals using this computer system without #
        # authority, or in excess of their authority, are #
        # subject to having all of their activities on this #
        # system monitored and recorded by system personnel. #
        # #
        # In the course of monitoring individuals improperly #
        # using this system, or in the course of system #
        # maintenance, the activities of authorized users #
        # may also be monitored. #
        # #
        # Anyone using this system expressly consents to such #
        # monitoring and is advised that if such monitoring #

2009年08月12日 01点08分 1
level 1
littles0907 楼主
        # reveals possible evidence of criminal activity, #
        # system personnel may provide the evidence of such #
        # monitoring to law enforcement officials. #
        # #
        #      This system/database contains restricted data.          #
        #                                                              #
        #################################################################
Solaris OS: .....
Veritas VxVM: .....
Qlogic driver: ....
WWNs of installed QLA HBAs:
.......
stty: : Invalid argument
stty: :
Invalid argument
stty: : Invalid argument
stty: : Invalid argument
stty: : Invalid argument
########################################################################
########################################################################
##       ##
##          Version of JDK Supported in qa-batch host       ##
## -------------------------------------------------       ##
## jre_1.5.0_06-b05 - Supported by wrapper class java15_06            ##
##       ##
## jre1.5.0_09      - Supported by wrapper class java15_09            ##
##       ##
## jdk1.6.0_13      - Supported by wrapper class java16_13            ##
##       ##
##       ##
########################################################################
########################################################################
然后就停在这里,没有出现提示符,必须强行abort退出。
有哪位能帮忙解决这个问题么?
ps: 用别的软件如SecureCRT能正常登录和执行。我必须用ruby编个程序,用这个用户名远程登录服务器,而且不知道密码。
在SecureCRT里的结果会多一个prompt:
[ /home/root ]->
然后可以输入其他命令,如bash。
2009年08月12日 01点08分 2
level 4
ssh上服务器后执行呀~
2010年01月22日 13点01分 3
1