0

I have Kali 4.19 loaded onto a Raspberry Pi 4, and am communicating with it using a ParrotOS VM on a separate host.

I noticed some strange behavior when sending commands to my Kali Pi over SSH. I can send familiar commands such as ifconfig and shutdown to it, and both have the expected behavior (the former shows the correct information about the remote machine, and the latter shuts it now).

When on the Kali Pi itself, if I open up a terminal and type either of the above commands, I get

brendon@kali:~$ ifconfig
bash: ifconfig: command not found
brendon@kali:~$ shutdown
bash: shutdown: command not found

I understand that ifconfig is deprecated, and that shutdown can come from different packages, so neither is necessarily guaranteed to exist.

What confuses me though is that it works over SSH, but not when on the machine. I assumed when I send a command, it gets encrypted as text, sent to the other machine, decrypted to text, then eval'd locally using a exec* call or something similar. Then the reverse happens to the response. That fact that it works over SSH though suggests that something else is going on.

If I which ifconfig over SSH, I get a return code of 1, which indicates that "one or more specified commands is nonexistent or not executable". And yet it still works.

Can someone explain what's happening here?

5
  • Is it the same user locally and via SSH? What is the output of type ifconfig in the SSH shell? Commented Aug 8, 2020 at 0:04
  • @HaukeLaging Yes, the same user for each test. And type ifconfig gives ifconfig is hashed (/usr/sbin/ifconfig). Commented Aug 8, 2020 at 0:06
  • 1
    Then $PATH is different in the local shell from the remote? Commented Aug 8, 2020 at 0:07
  • Doh, sorry. Yes. This ended up being a dumb question. The SSH session contains sbin directories, whereas the local session doesn't. I'll just change the default PATH on the machine. Thanks. Commented Aug 8, 2020 at 0:10
  • However, I have no idea how that could happen. Commented Aug 8, 2020 at 0:12

1 Answer 1

3

Something creates a difference between the $PATH setting for the local shell and the remote shell. The reason for the error message is that the parent directory of ifconfig is missing in the local shell $PATH.

1
  • I haven't changed anything, so it might be due to the default setting of Kali (I have very little experience with Kali so far). It seems a bit odd though that SSH sessions have access to more locations than sessions on the machine. Commented Aug 8, 2020 at 0:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.