cygwin
cygwin

Reputation: 1

How do I run cygwin ssh properly on powershell?

My OS is Windows 10 (x64) and I installed both Powershell 7 and cygwin.

Then, I installed "sshpass" using cygwin.

And, here are the cases I am experiencing right now.

  1. From cmd, if I enter "C:\cygwin64\bin\mintty.exe -", cygwin pops up with initial directory "~". Then, if I type "sshpass -p<password> ssh <username>@<host>", it perfectly works smoothly!

  2. From cmd, if I enter "C:\cygwin64\bin\mintty.exe", cygwin pops up with directory "/cygdrive/c/Users/myname". Then, if I type "sshpass -p<password> ssh <username>@<host>", it asks me to type the password. This means that sshpass is not working correctly here.

  3. From powershell, if I type "C:\cygwin64\bin\sshpass.exe -p<password> C:\cygwin64\bin\ssh <username>@<host>", nothing happens.

My questions are the following:

  1. How do I properly run sshpass command in Powershell?

  2. Let's say my ip address is 1.1.1.1 and I am connecting to a server whose ip is 2.2.2.2, and both computers OS systems are Windows. When I connect to the server through ssh, it shows the "cmd" terminal of the server. How can I change it to show "cygwin" terminal when I connect to the server?

I am having very hard time fixing this out.. Thank you very much in advance..

Upvotes: 0

Views: 650

Answers (1)

Wyatt_LandWalker
Wyatt_LandWalker

Reputation: 309

I am not sure i am getting this, anyway, if i understand correctly you have a hard time launching sshpass from powershell.

Try using Start-Process commandlet: (maybe add the full path to ssh in arguments (?))

start-process -filepath C:\cygwin64\bin\sshpass.exe -ArgumentList '-p<password> ssh <username>@<host>' -Wait -NoNewWindow

Anyway instead of reaching linux commands to windows and run it from powershell, why don't you check powershell modules?

ssh using powerShell script by passing the password along with the Commnad

Also, Powershell Remoting towards linux is a thing nowadays, and it runs over ssh (not bash afaik)

Upvotes: 1

Related Questions