Thursday, October 28, 2021

[SOLVED] Use plink/ssh in a Batch

Issue

I try to connect from my local machine to a server with plink. From the server i need to connect to an other local mashine over ssh to perform some commands

my try is:

plink -load "puttyProfile" -pw password "ssh admin@address"

which works. But now i want to give the ssh an operation like this

plink -load "puttyProfile" -pw password "ssh admin@address "cd .."   "

my error looks very strange something like this

#< CLIXML <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" .... 

which goes on for a while. Please give some advise =D Greetings


Solution

Ok got it myself.. on the last pc where i want to do the operations ssh was using powershell and not command prompt. It seems like powershell cant work with the list of operations given over ssh. i changed to command promp and it works bettet. Also i need to change the inner " to ' chaining commands wasnt a problem ether when u use && the ; wont work

ssh admin@address "ssh admin2@address2 'cd ..  &&  dir'  ; echo hey "


Answered By - Olgidos