0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.