Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Remote execution via Ruby-SSH starts different shell - solved

    Scheduled Pinned Locked Moved General pfSense Questions
    3 Posts 2 Posters 696 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stony999
      last edited by

      Hello,

      we are using net/ssh in Ruby to execute scripts on a PfSense machine, in order to do some checks for Nagios. Actually it is a brand new Pfsense applicance.
      The code is roughly the following:

      
      Net::SSH.start(@host, @user, {:password=>@pass}) do |ssh|
         erg=ssh.exec! "ls -al"
         p erg
      end
      
      

      When we execute this, we get a message, that the parameter "l" in "ls -al" is wrong. This is strange to me, as this works on a normal command line. Passing "ls -a" works however and produces the desired output.
      "echo $0" shows not output, so I suspect, there is something wrong with the shell here.

      Remotely executing "env" displays the following

      
      SSH_CLIENT=192.168.12.252 53798 22
      LOGNAME=admin
      FTP_PASSIVE_MODE=YES
      MAIL=/var/mail/admin
      PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
      PWD=/root
      TERM=su
      USER=admin
      HOME=/root
      SSH_CONNECTION=192.168.12.252 53798 192.168.12.254 22
      SHELL=/etc/rc.initial
      BLOCKSIZE=K
      
      

      We also tried to execute "tcsh -c <command></command>" but he complains about the "-c" parameter.

      So I am confused, which shell is actually run, when remotely executing via ssh. And how I can run an remote command via tcsh?

      Any help is appreciated.

      Edit: Marked a solved

      1 Reply Last reply Reply Quote 0
      • jimpJ
        jimp Rebel Alliance Developer Netgate
        last edited by

        Are you using admin@ for the account? If so, don't. Use root@.

        The way admin@ is setup it doesn't support commands like that, or scp. root@ uses the same password but will work for those functions.

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • S
          stony999
          last edited by

          Thank you, that did the trick.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.