Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

run bash script in PowerShell with ssh fails with invalid format

I created a simple bash script that runs fine on Ubuntu 18/20. Decided to port it onto PowerShell. I start PowerShell in Windows 10. Then type: ssh 192.168.1.56 This allows me to reach the target. (the key is located in /c/users/joe90/.ssh/)

On the other hand, the bash script does the same thing:

#!/bin/bash

ssh 192.168.1.56 

Yet, I keep getting this error: load pubkey "/c/Users/joe90/.ssh/mykey-xyz": invalid format

The only thing I was able to sort out is that typing from PowerShell: ssh -V return ==> OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

But when the myBash.sh bash script runs (/usr/bin/bash ...): ssh -V return --> OpenSSH_8.3p1 ...

Any thoughts ?

Additional Notes: The answer seems to lie here. It does ssh onto target but always leave this error mentioned. I tried to make a public key with no success.

question from:https://stackoverflow.com/questions/65854109/run-bash-script-in-powershell-with-ssh-fails-with-invalid-format

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Run

/usr/bin/ssh 192.168.1.56

instead (assuming this is the one you want to run).

Verify it using

/usr/bin/ssh -V

form bash, or

sh -c '/usr/bin/ssh -V'

from powershell.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...