SSH can't send command











up vote
0
down vote

favorite












Description



I first encountered this problem when I tried to use SCP to another computer over LAN, and get
zsh:1: command not found: scp

Now before anyone asks: yes I have SSH installed.

I can use ssh to log into the other computer just fine.

The problem is SCP, and ssh [user@]hostname [command] both result in zsh:1: command not found: [command].



Testing



I tried using SCP with localhost



systemctl start sshd.service
scp /home/user/asdf.log user@127.0.0.1:/home/user/test/asdf.log
...
zsh:1: command not found: scp


And then sending a command:



ssh user@127.0.0.1 ls
...
zsh:1: command not found: ls


ssh user@127.0.0.1 works as expected.



I used the -v switch, and the info looked normal.

I tried switching to Bash instead of ZSH; same error.



Finally, I tried root login, and that worked



ssh root@127.0.0.1 ls
...
Desktop
Documents
Music
...


SSH Config:



~/.ssh/config: nothing



#/etc/ssh/sshd_config
PermitRootLogin yes # this is bad; for testing only
AuthorizedKeysFile .ssh/authorized_keys
ChallengeResponseAuthentication no
UsePAM yes
PrintMotd no #pam does that
Subsystem sftp /usr/lib/ssh/sftp-server


Using Arch Linux with openssh 7.9p1



TL;DR



It looks like the environment isn't getting set (not even PATH)
for SCP and single command SSH. But, for root login it is getting set properly.

Any ideas about this?



Update



It's something with my user shell config.

I added a new, blank user account, and using SCP into that worked fine.










share|improve this question




























    up vote
    0
    down vote

    favorite












    Description



    I first encountered this problem when I tried to use SCP to another computer over LAN, and get
    zsh:1: command not found: scp

    Now before anyone asks: yes I have SSH installed.

    I can use ssh to log into the other computer just fine.

    The problem is SCP, and ssh [user@]hostname [command] both result in zsh:1: command not found: [command].



    Testing



    I tried using SCP with localhost



    systemctl start sshd.service
    scp /home/user/asdf.log user@127.0.0.1:/home/user/test/asdf.log
    ...
    zsh:1: command not found: scp


    And then sending a command:



    ssh user@127.0.0.1 ls
    ...
    zsh:1: command not found: ls


    ssh user@127.0.0.1 works as expected.



    I used the -v switch, and the info looked normal.

    I tried switching to Bash instead of ZSH; same error.



    Finally, I tried root login, and that worked



    ssh root@127.0.0.1 ls
    ...
    Desktop
    Documents
    Music
    ...


    SSH Config:



    ~/.ssh/config: nothing



    #/etc/ssh/sshd_config
    PermitRootLogin yes # this is bad; for testing only
    AuthorizedKeysFile .ssh/authorized_keys
    ChallengeResponseAuthentication no
    UsePAM yes
    PrintMotd no #pam does that
    Subsystem sftp /usr/lib/ssh/sftp-server


    Using Arch Linux with openssh 7.9p1



    TL;DR



    It looks like the environment isn't getting set (not even PATH)
    for SCP and single command SSH. But, for root login it is getting set properly.

    Any ideas about this?



    Update



    It's something with my user shell config.

    I added a new, blank user account, and using SCP into that worked fine.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Description



      I first encountered this problem when I tried to use SCP to another computer over LAN, and get
      zsh:1: command not found: scp

      Now before anyone asks: yes I have SSH installed.

      I can use ssh to log into the other computer just fine.

      The problem is SCP, and ssh [user@]hostname [command] both result in zsh:1: command not found: [command].



      Testing



      I tried using SCP with localhost



      systemctl start sshd.service
      scp /home/user/asdf.log user@127.0.0.1:/home/user/test/asdf.log
      ...
      zsh:1: command not found: scp


      And then sending a command:



      ssh user@127.0.0.1 ls
      ...
      zsh:1: command not found: ls


      ssh user@127.0.0.1 works as expected.



      I used the -v switch, and the info looked normal.

      I tried switching to Bash instead of ZSH; same error.



      Finally, I tried root login, and that worked



      ssh root@127.0.0.1 ls
      ...
      Desktop
      Documents
      Music
      ...


      SSH Config:



      ~/.ssh/config: nothing



      #/etc/ssh/sshd_config
      PermitRootLogin yes # this is bad; for testing only
      AuthorizedKeysFile .ssh/authorized_keys
      ChallengeResponseAuthentication no
      UsePAM yes
      PrintMotd no #pam does that
      Subsystem sftp /usr/lib/ssh/sftp-server


      Using Arch Linux with openssh 7.9p1



      TL;DR



      It looks like the environment isn't getting set (not even PATH)
      for SCP and single command SSH. But, for root login it is getting set properly.

      Any ideas about this?



      Update



      It's something with my user shell config.

      I added a new, blank user account, and using SCP into that worked fine.










      share|improve this question















      Description



      I first encountered this problem when I tried to use SCP to another computer over LAN, and get
      zsh:1: command not found: scp

      Now before anyone asks: yes I have SSH installed.

      I can use ssh to log into the other computer just fine.

      The problem is SCP, and ssh [user@]hostname [command] both result in zsh:1: command not found: [command].



      Testing



      I tried using SCP with localhost



      systemctl start sshd.service
      scp /home/user/asdf.log user@127.0.0.1:/home/user/test/asdf.log
      ...
      zsh:1: command not found: scp


      And then sending a command:



      ssh user@127.0.0.1 ls
      ...
      zsh:1: command not found: ls


      ssh user@127.0.0.1 works as expected.



      I used the -v switch, and the info looked normal.

      I tried switching to Bash instead of ZSH; same error.



      Finally, I tried root login, and that worked



      ssh root@127.0.0.1 ls
      ...
      Desktop
      Documents
      Music
      ...


      SSH Config:



      ~/.ssh/config: nothing



      #/etc/ssh/sshd_config
      PermitRootLogin yes # this is bad; for testing only
      AuthorizedKeysFile .ssh/authorized_keys
      ChallengeResponseAuthentication no
      UsePAM yes
      PrintMotd no #pam does that
      Subsystem sftp /usr/lib/ssh/sftp-server


      Using Arch Linux with openssh 7.9p1



      TL;DR



      It looks like the environment isn't getting set (not even PATH)
      for SCP and single command SSH. But, for root login it is getting set properly.

      Any ideas about this?



      Update



      It's something with my user shell config.

      I added a new, blank user account, and using SCP into that worked fine.







      linux ssh scp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 at 1:22

























      asked Nov 17 at 1:06









      SilentStorm

      133




      133






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I figured out the problem.



          There was a line in my ~/.pam_environment setting my path.
          PATH DEFAULT=${PATH}:/home/@{PAM_USER}/bin

          This for some reason puts /home/user/bin in my path 3 times, and adds an extra colon.

          Why it does this, I'm not sure.

          But setting my PATH in ~/.profile instead, fixed the problem.



          I guess, the bad PATH assignment was discarded by ssh, but not by my regular login.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1376136%2fssh-cant-send-command%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            I figured out the problem.



            There was a line in my ~/.pam_environment setting my path.
            PATH DEFAULT=${PATH}:/home/@{PAM_USER}/bin

            This for some reason puts /home/user/bin in my path 3 times, and adds an extra colon.

            Why it does this, I'm not sure.

            But setting my PATH in ~/.profile instead, fixed the problem.



            I guess, the bad PATH assignment was discarded by ssh, but not by my regular login.






            share|improve this answer

























              up vote
              0
              down vote













              I figured out the problem.



              There was a line in my ~/.pam_environment setting my path.
              PATH DEFAULT=${PATH}:/home/@{PAM_USER}/bin

              This for some reason puts /home/user/bin in my path 3 times, and adds an extra colon.

              Why it does this, I'm not sure.

              But setting my PATH in ~/.profile instead, fixed the problem.



              I guess, the bad PATH assignment was discarded by ssh, but not by my regular login.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                I figured out the problem.



                There was a line in my ~/.pam_environment setting my path.
                PATH DEFAULT=${PATH}:/home/@{PAM_USER}/bin

                This for some reason puts /home/user/bin in my path 3 times, and adds an extra colon.

                Why it does this, I'm not sure.

                But setting my PATH in ~/.profile instead, fixed the problem.



                I guess, the bad PATH assignment was discarded by ssh, but not by my regular login.






                share|improve this answer












                I figured out the problem.



                There was a line in my ~/.pam_environment setting my path.
                PATH DEFAULT=${PATH}:/home/@{PAM_USER}/bin

                This for some reason puts /home/user/bin in my path 3 times, and adds an extra colon.

                Why it does this, I'm not sure.

                But setting my PATH in ~/.profile instead, fixed the problem.



                I guess, the bad PATH assignment was discarded by ssh, but not by my regular login.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 17 at 1:47









                SilentStorm

                133




                133






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1376136%2fssh-cant-send-command%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Plaza Victoria

                    In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                    How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...