Fastest method for windows->linux command line control

2

1

What is the fastest method to get at a linux CLI in windows? (See this earlier question on StackOverflow.)

Basically my goal is to use a batch file in windows to control various things on my ubuntu mediacenter/server. Music being the main thing of course but it seems fairly invaluable, I can imagine a lot of people wanting this.

I am currently using ssh with plink, i can login send a command all in one line, perfect. Almost... there is a wait time of something like 5~6seconds between me hitting the command and it happening.

I assume that this is the authentication with ssh screwing me over since I have to login and authenticate before each command which is slow.

Possible ideas:

  • Somehow run the ssh CLIENT as a service on the windows box then when I want to send a command send it through the already open session. This seems doable. I'd prefer a tool to programming my own ssh app though to achieve this...
  • I did something wrong and logging in shouldn't take so long
  • plink is slow
  • batch files are slow (i can't imagine)

Ambiwlans

Posted 2009-11-19T08:29:44.520

Reputation: 383

Answers

2

I'd install a ssh client on the windows box and compare the speed then with the speed you're getting using plink. You should be able to configure it to use a key file so that you don't have to login when you connect, once connected you'll only need to authenticate if you change user.

Amos

Posted 2009-11-19T08:29:44.520

Reputation: 216

If i log into a regular ssh session like putty the commands go through fast, that's not the problem. Plink (the way I can send a command without me typing anything...) logs in, authenticates, sends the command, DCs with no intervention. I imagine using this even with a key auth I'd need to authenticate everytime I sent a command... I mean otherwise what security is there? No tunnel is being maintained since plink closes itself instantly. Or am I missing something. – Ambiwlans – 2009-11-19T17:55:50.307

It depends then whether you want ssh to maintain a tunnel which you just use for all commands. Do your commands have to live in the batch file (do you have to be able to edit them easily) or could you get away with something sending udp or tcp packets over the network to trigger a bash file on the media server. Is your network public? – Amos – 2009-11-19T19:42:05.647

You could log in with ssh if you did need to edit the commands, and use a console text editor like emacs to edit the bash file. – Amos – 2009-11-19T19:43:18.500

"want ssh to maintain a tunnel which you just use for all commands." how? I can edit batch files over vpn or ssh or w/e that isn't a remote concern... "could you get away with something sending udp or tcp packets over the network to trigger a bash file on the media server." Yeah, a vpn is maintained with hamachi (can't setup ports other than 80 for webserver to be truly public because of dsl), anyways it counts as public from my pov. So is there an easy way to do this? Sounds like you are suggesting coding my own server which I don't really look forward to... modify another one maybe... – Ambiwlans – 2009-11-19T21:12:16.853

Do you have other things you need to do remotely, or is it just rhythmbox you need to control. Do you mean that you're connecting over your own network or over a publicly accessible network? If you're reasonably private why not just configure something to listen for a udp packet from the ip address of your windows box, and use receipt to trigger a skip ahead in rhythmbox. I'm sure you could knock something out in Python in about an hour. – Amos – 2009-11-19T23:11:44.070

1The udp packet could be sent to a specific port for a specific option, or for security you could configure a reasonably random sequence of ports for the client and server to follow. The packet could contain specific code words read in sequence from a file on both machines no encryption necessary. Or you could go the tcp/ip route and seekl toestablish socket connections. – Amos – 2009-11-19T23:14:02.800

Writing a server ap in python wasn't something I relished. But looking around with more keywords you used led me to PortKnocking! knockd looks like exactly EXACTLY the thing I need, I can set it to only work over vpn so its 100% secure and it seems very fast. And unless there is something in nix I haven't yet heard of to listen to ports and run apps (probably out there knowing linux...) it looks dead simple to set up. Thanks for all your help. – Ambiwlans – 2009-11-20T01:55:55.830

I thought of port knocking but assumed it would be very complicated to set up, so my idea was basically a cut down version of port knocking. – Amos – 2009-11-20T10:37:00.980

1

One alternative method you may consider is to turn your batch file on windows into a linux bash script as far as possible - this will reduce the number of 5-6second waits.

e.g

#!/bin/bash
commandhere
commandhere

This way you only have to reauthenticate when you want to have user input, 5-6seconds seems a bit excessive for login though. If when you authenticate using putty it takes it a long time to ask for a password then try editing your /etc/ssh/ssh_config file and comment out:

GSSAPIAuthentication yes
GSSAPIDelegateCredentials no

Elliot Hughes

Posted 2009-11-19T08:29:44.520

Reputation: 360