4

I want to run for example this command : ip addr on my remote system.
I do it like this :

ssh username@ip ip addr

but I got this error :

bash: ip: command not found

when I connect to remote system and then run this command it is ok, I mean it is not caused by uninstalled package. I want to get the result without connecting permanently.

fa7eme
  • 43

1 Answers1

7

easy: ssh remotehost "/sbin/ip addr"

Reason, the remote shell launched by ssh command to execute ip, have not ENV or just a basic one, and ip is not in the $PATH of the remote shell. So either you specify the full path of the command, or you source a working environment in the remote shell before running command.

netmonk
  • 1,870
  • 1
    you can have a look to this question https://unix.stackexchange.com/questions/332532/how-to-set-path-when-running-a-ssh-command – netmonk Sep 05 '20 at 09:19