Plink error - "unix shell commands cannot be executed using this account" [closed]

StackOverflow https://stackoverflow.com/questions/16882807

  •  30-05-2022
  •  | 
  •  

سؤال

I'm trying to run plink.exe to execute a command on a remote UNIX machine. When logging in using Putty, my command is executed successfully. My problem is when using the same credentials (same user and password) to execute the same command exactly with plink.

I keep getting a message "UNIX shell commands cannot be executed using this account". I get the same message for every command I type in.

The syntax I'm using to run the command is this :

  C:>plink.exe -pw PASSWORD -m FILENAME USER@REMOTEHOST

I also tried typing it differently, for example:

  C:>plink.exe -l USER -pw PASSWORD -ssh REMOTEMACHINE -m FILENAME

but the result is always the same.
I am using a user with Admin capabilities.

I'll be glad to get any assistance.

هل كانت مفيدة؟

المحلول

I think the issue has to do with interactive vs. non-interactive modes. When you login with putty or you call plink without specifying a command, then you are in interactive mode.

However, if you specify a command, or a file with a list of commands, then the remote shell will treat your login as non-interactive, and apparently reject your connection.

I'm not exactly sure how the remote decides to treat your login as interactive or not. I would suggest to try one of these options:

  1. Put your commands in a script.sh shell script and copy it to the remote server, and run it like this:

    C:>plink.exe -pw PASSWORD USER@REMOTEHOST "bash /path/to/remote/script.sh"
    
  2. If you don't want to put the script on the remote server, you can try to redirect local input to the remote bash, but I'm not sure this works in Windows:

    C:>plink.exe -pw PASSWORD USER@REMOTEHOST bash < C:\path\to\local\script.sh
    

In both suggestions the hope is that by sticking bash there, your shell will be treated as interactive.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top