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

    [SOLVED..Sorta..workarnd] How to concatenate SSH commands to PFS for scripting?

    Scheduled Pinned Locked Moved General pfSense Questions
    8 Posts 3 Posters 2.1k 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.
    • D
      dylanh724
      last edited by

      EDIT 2: Solved by adding Sudo, making no password for root. Installed via web GUI. I still think it's INCREDIBLY dumb that there's no concatenation for the pfs gui (multiple  commands for scripting, "such as 7 && yahoo.com" to ping…....... so only 1/2 resolved

      **EDIT: Only 1/2 Solved by checking out this post: https://forum.pfsense.org/index.php?topic=43641.msg226099#msg226099\

      This is still an issue. There are some commands I need root access to..**

      ^ Subject says it all.

      Most SSH scripting connects, types a lot of concatenated commands (cmd1 && cmd2 && exit) for a chain of cmds.

      However, I noticed in the main interface ("Choose a cmd#"), nothing will concatenate! I tried "&", "&&", ";", and "|".

      This makes it REALLY difficult to do anything with scripting. For something so advanced, surely there has to be something I'm missing….

      For the sake of example, let's say I want to ping, either in PFS or in shell, both won't work because concatenation is required:

      Something like "7" && "yahoo.com" .... without conc. it'll just press 7, then RELOG IN and type yahoo.com (which just refreshes the screen, since it's not on 7 anymore).

      It won't let me break to shell to utilize concatenation because I have to get to shell first and add commands after ;) the most I can do now is get to shell, then reconnect back to the main screen ;p

      Cheers

      1 Reply Last reply Reply Quote 0
      • D
        doktornotor Banned
        last edited by

        As noted on the other topic. Create another admin account and use sudo package.

        1 Reply Last reply Reply Quote 0
        • D
          dylanh724
          last edited by

          @doktornotor:

          As noted on the other topic. Create another admin account and use sudo package.

          Sudo package for this version of bsd is broken (moved to another host or something?), which I also read in another thread.

          This sophisticated software and no way to concatenate commands..? I find this hard to believe..

          Alternately, how can I change shells for the main admin on initial login? If I look at /etc/master.passwd it shows a second account start at /bin/tcsh while admin starts at init.d  .. I tried editing this file but doesn't seem to do anything. How can I also make main admin load in /bin/tcsh?

          1 Reply Last reply Reply Quote 0
          • D
            doktornotor Banned
            last edited by

            @dylanh724:

            Sudo package for this version of bsd is broken (moved to another host or something?), which I also read in another thread.

            Complete nonsense. Install it from System - Packages and move to "concatenation" or what on earth you mean (strongly suspect you should start by reading man ssh instead).  ::)

            1 Reply Last reply Reply Quote 0
            • D
              dylanh724
              last edited by

              via the GUI? I'll take a look.

              Concatenation is just joining multiple commands on 1 line, mostly for scripting or SSH

              (from ssh) "echo blah && echo blah2" then this will display:
              blah
              blah2

              (2 commands, 1 line).

              So I'd like to ping from main screen,

              7 && yahoo.com

              but won't work:

              Because of the main initial screen, it won't allow this, so nothing at all works for scripting– Let's say I want to ping, I type 7, then ssh has to login AGAIN and the screen resets, so the next screen is..... the same screen that started ;p

              1 Reply Last reply Reply Quote 0
              • D
                dylanh724
                last edited by

                ahhh the GUI sudo add was incredibly easy – cheers. I have everything I want now

                1 Reply Last reply Reply Quote 0
                • D
                  dylanh724
                  last edited by

                  (if anyone was curious, /bin/tcsh leads directly to shell, so in /etc/rc.initial, you can comment out opmode and instead put /bin/tcsh .. havent tested if it works on reboot. Leads straight to root shell

                  1 Reply Last reply Reply Quote 0
                  • R
                    ryan206
                    last edited by

                    Are you just trying to go straight to a shell rather than having the config wizard (or whatever it's called)? If that is what you're trying to do, changing /etc/rc.initial probably isn't the best way to go about this.

                    The reason why /etc/rc.initial is being executed after logging in via SSH is because /root/.profile is set to start it for interactive sessions. If you want to immediately launch tcsh rather than rc.initial, change /root/.profile to use /bin/tcsh rather than changing rc.initial. Doing it this way should leave /etc/rc.initial intact in case you need to use it in the future.

                    Edit:

                    Reread your original post, sounds like you just wanted to get straight into a root shell rather than use a script to enter options on the wizard

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