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

    Allowing ssh straight to the shell

    Scheduled Pinned Locked Moved Firewalling
    11 Posts 4 Posters 4.2k 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
      DominikHoffmann
      last edited by

      I had my DD-WRT router set up so that I could ssh to it. When the connection was made, I ended up in the router's shell. On my pfSense box I get the text-interface menu, where the shell is an option. This means that I cannot reach the shell directly, which I would like to do, in order to tunnel ports to other hosts on the network.

      Is there a way to configure pfSense to have ssh connect to the shell and perhaps launch the menu through a shell command?

      1 Reply Last reply Reply Quote 0
      • N
        NOYB
        last edited by

        This is what I do for directly running tcpdump through ssh.  Though it's not what you are attempting maybe it could spark some ideas.

        
        "C:\Program Files\PuTTY\plink.exe" -ssh -pw password root@pfSense.localdomain tcpdump -p -n -nn -s 0 -U -w - -i bfe0 not port 22 and src or dst 192.168.2.1 | "C:\Program Files\Wireshark\wireshark.exe" -i - -k
        
        

        or replace password with i option and key file

        
        "C:\Program Files\PuTTY\plink.exe" -ssh -i "C:\Program Files (x86)\WinSCP\Keys\pfSense\id_rsa_4096_SSH_Private_Key.ppk" root@pfSense.localdomain tcpdump -p -n -nn -s 0 -U -w - -i bfe0 not port 22 and src or dst 192.168.2.1 | "C:\Program Files\Wireshark\wireshark.exe" -i - -k
        
        
        1 Reply Last reply Reply Quote 1
        • D
          DominikHoffmann
          last edited by

          What exactly does that accomplish?

          By the way, I am on a Mac and have Terminal instead of Putty.

          1 Reply Last reply Reply Quote 0
          • johnpozJ
            johnpoz LAYER 8 Global Moderator
            last edited by

            if you login with a different user than root/admin, you will not get the menu and just the shell..

            So see if I login with root or admin you get the menu your talking about.  I created a johnpoz account, using the same public key for auth.  And boom your straight into the shell.

            nonadmin_root.png
            nonadmin_root.png_thumb

            An intelligent man is sometimes forced to be drunk to spend time with his fools
            If you get confused: Listen to the Music Play
            Please don't Chat/PM me for help, unless mod related
            SG-4860 24.11 | Lab VMs 2.8, 24.11

            1 Reply Last reply Reply Quote 1
            • N
              NOYB
              last edited by

              @DominikHoffmann:

              What exactly does that accomplish?

              By the way, I am on a Mac and have Terminal instead of Putty.

              It starts tcpdump on pfSense and streams it to local Wireshark for live capture.

              I have several "canned" commands for common stuff.  Similar capability is under development for inclusion in Wireshark.  Then the external ssh command won't be needed anymore.  That will be really nice.

              Netcat can be used instead of plink.  Some people do that.  But since I'm using PuTTY/WinSCP plink is already on the system.  So I make use of that.

              What John said is probably what you are looking for.  My guess is that the account he created just has a different shell assigned to it than what the root account has.  Have not verified though so could be completely wrong about what is going on with that.

              Or maybe the root account just runs some scripts at login time.

              1 Reply Last reply Reply Quote 1
              • D
                DominikHoffmann
                last edited by

                Going with a separate user ID is just fine for my application.

                Thanks to you both!

                1 Reply Last reply Reply Quote 0
                • johnpozJ
                  johnpoz LAYER 8 Global Moderator
                  last edited by

                  "Thanks to you both!"

                  You sure about that??  Seems NOYB got the thank you for his post, which didn't answer your question.  But I posted up screenshots showing you that it works, and yet I get bumpkis - heheh.. atleast it seems you didn't smite me.. ROFL!!!

                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                  If you get confused: Listen to the Music Play
                  Please don't Chat/PM me for help, unless mod related
                  SG-4860 24.11 | Lab VMs 2.8, 24.11

                  1 Reply Last reply Reply Quote 1
                  • D
                    DominikHoffmann
                    last edited by

                    I haven’t used this forum much, and haven’t used this forum format elsewhere and therefore didn’t realize that one can hand out only one Thanks per thread started.

                    1 Reply Last reply Reply Quote 0
                    • johnpozJ
                      johnpoz LAYER 8 Global Moderator
                      last edited by

                      You can remove his ;)  And give it to the person who actually helped you ;)

                      An intelligent man is sometimes forced to be drunk to spend time with his fools
                      If you get confused: Listen to the Music Play
                      Please don't Chat/PM me for help, unless mod related
                      SG-4860 24.11 | Lab VMs 2.8, 24.11

                      1 Reply Last reply Reply Quote 1
                      • JKnottJ
                        JKnott
                        last edited by

                        If I'm not mistaken, this is determined by /root/.shrc which, when it detects root login, runs /etc/rc.initial.

                        It shouldn't be too hard to modify .shrc to not run the shell.

                        PfSense running on Qotom mini PC
                        i5 CPU, 4 GB memory, 32 GB SSD & 4 Intel Gb Ethernet ports.
                        UniFi AC-Lite access point

                        I haven't lost my mind. It's around here...somewhere...

                        1 Reply Last reply Reply Quote 1
                        • D
                          DominikHoffmann
                          last edited by

                          Setting up a separate user does the trick for me. It also adds another layer of protection against brute-force attacks, although I have shutdown password login.

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