Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd"

i am trying in this manner "

ssh username@servername "cd c:/data/mystuff ; ls "

Note : I already established the passwordless authentication between linux and windows and i can successfully run the following command : ssh username@server

Please help me

Well, ls is not a windows command. Try dir instead.

Robin

i even tried using : " cd c:/" or cd c:\data\mystuff It just errors out saying Could not start program (command name i specified .

Its not working just for the command cd c :

---------- Post updated at 04:39 PM ---------- Previous update was at 04:38 PM ----------

now i just tried ssh username@servername "dir"

This actually should go to the home directory of the user: username and list the contents of the directory , even this seems to have not working :frowning:

Just adding my 2 cents here.
Try this first (don't add the other commands!):

ssh username@server

Does it even connect to the server? Do you get a confirmation? Are you sure that the remote server is actually listening on port 22? (The default for ssh)
If you can connect to the server, try one of those commands at a time.
This step-by-step approach should give you a hint about where the script is stuck during its automated login to the server and execution of those commands.
Let us know the results.

--NOTE: I read again one of your first posts where you say that you can run the connection command. I haven't paid attention to that fact before. Anyway, please post here the results. (Screen caps with blur over username and server would also be helpful)

1 Like

Hello gacanepa

I have attached two screen shots : one where i just tried to do a DIR on the remote server along with SSH command
and other where i try to do cd to a particular directory on the remote server.

You missed my warning

Please do this and this only:

ssh username@server

Once you get a confirmation, run the following command to find out the current working directory in your Windows server:

ECHO %CD%

Then (and only then) try to cd to another directory.