Invalid command:’scp -t /path/to/dir/’
This article explains the cause of the “Invalid command:’scp -t xxxxx'” error and how to solve it.
Researching this error actually brought to my attention two undocumented switches of the scp command: “-f” and “-t”.
These flags are automatically added to the command when it’s run depending on whether you’re copying to (-t) or from (-f):
Command Actual command run
scp ./myfile.txt name@server:/myfile.txt scp -t /myfile.txt scp name@server:/myfile.txt ./myfile.txt scp -f /myfile.txt
This can be seen when running scp with the -v verbose/debug flag:
linux:/ # scp -v myfile.txt name@server:/home/name/myfile.txt Executing: program /usr/bin/ssh host server, user admin, command scp -v -t /home/admin/myfile.txt <snip> CLINFR0329 Invalid command:'scp -v -t /home/name/myfile.txt'. linux:/ #
Besides being of interest regarding the -f and -t flags, the only thing that we can really glean from this is that the remote system doesn’t recognise the command, the flags or both.
In the case of Checkpoint Gaia it is down to the fact that the default shell is “clish” and not bash which is required for scp.
To mitigate this we can set the default login shell to be bash, either temporarily or permanently, using a quick command from clish:
gw-8f991f> set user admin shell /bin/bash gw-8f991f> save config gw-8f991f>
To make this change only temporarily, do not use the “save config” command.
To revert the change:
gw-8f991f> set user admin shell /etc/cli.sh gw-8f991f> save config
Hope you save yourself some time!