简体   繁体   中英

Can I ssh to Mac using Windows Command line without using other tool like putty?

I have a CI system on my Windows to build my server code.

Nowadays, I also want to autobuild my IOS project daily, but it can only build in Mac system.

So I write a shell script that can build my ios project on my Mac, and I want to remotely execute my script from Windows.

How can I write a batch file on Windows to remote access my Mac and execute my script there? So I can make my CI system to execute that batch file everyday automatically.

Or... does anyone got other better ways to do this thing?

Thanks!

Get "plink" from the PuTTY download page. Put the command(s) to kick off your Mac shell script in a file (eg "maccommands.txt") on your Windows computer. Then make a batch file that contains:

plink -l macusername -m maccommands.txt your.mac.ip.address

If you don't want to be prompted for a password every time, you could make a public-private keypair with an empty passphrase using PuTTYgen. Save the private key as "pc_rsa.ppk" (or whatever you want to call it). Copy the public key out of the PuTTYgen window to the clipboard, and paste it in a text editor and save it (eg as "pc_rsa_pub.txt").

Then transfer the file with public key over to the Mac, and add its contents to the end of ~/.ssh/authorized_keys, eg with cat pc_rsa_pub.txt >> ~/.ssh/authorized_keys Then add -i pc_rsa.ppk to the plink command above to use your private key.

(This obviously has security implications, so protect the private key file. You could also use -pw password but that has even greater security implications as the password would be plainly visible within your batch file.)

Another solution is to use openssh. The benefit is not having to use an alternative format for your keys.

You can install Git for Windows . During the installation choose the third option of being able to use the "unix" tools from the command line.

I have a small wrapper utility that loads the agent to memory in github (#selfplug)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM