0

Thanks for looking into my concern.

I am running a command on remote linux server from windows, using plink. Here's the command I am running

echo y | plink -v -pw %Linux-pw% -P %port% %Linux-user%@%Linux-Machine% rm -rf /root/jenkins/Sandbox/project1

If I execute this command I see the below error in jenkins.

11:53:17 plink: unknown option "-rf"

Strange thing is I have the same command in two jenkins jobs. One working fine and one job is throwing this issue.

Could anyone suggest something on this.

Ras
  • 543
  • 1
  • 9
  • 25

1 Answers1

2

You can get this behavior, when the %port% variable resolves to an empty string.

Then you get this:

echo y | plink -v -pw password -P user@machine rm -rf /root/jenkins/Sandbox/project1

What takes user@machine as a port number, rm as a hostname and -rf as an additional switch to Plink.


Also, never automate host key verification (echo y)!

For the correct solution see How to pass echo y to plink.exe for first connection.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Brilliant. I missed port variable. Thank you so much. – Ras Jul 14 '17 at 18:12
  • Also, never automate host key verification (echo y)! @Martin Prikryl : Can I know the reason for this? – Ras Jul 19 '17 at 20:56
  • Host key verification is there to protect your against [man-in-the-middle attacks](https://en.wikipedia.org/wiki/Man-in-the-middle_attack). If you automate the verification, you may easily end up sending your username and password to the hacker. – Martin Prikryl Jul 21 '17 at 09:57