Question

Is there any way to execute a ssh connection with out use interactive password autentification and non public keys, I need too run a command in the remote server all this with out manual intervention, I know that i can use a script but I don´t have any example. The application will be running in different machines so it's a bit hard creating a key public for every machine.

No correct solution

OTHER TIPS

Everything is possible with the right configurations, but there are some security points to consider.

  • You certainly don't want everyone on the net to be able to execute any command on your server. So simply allowing everything is not a good idea.

  • Everyone who has your application on a computer in her control can do everything what your application can do ... and maybe more, if the application has limits only build in itself, not the server side.

  • You can distribute a private key with your application (and pass to SSH on connection), but of course then anyone having the application can extract this key. (If the application can access it, so can do any attacker who has control over it.)

  • You could also distribute a password with your application and somehow pass it to ssh, but still, in principle anyone who has the application can get the password.

  • If there is always the same command to be executed (maybe with different inputs), you can force this specific command at the server-side - for example, for a specific public key in the authorized_keys file. Or you could create a SSH subsystem and only allow this by server configuration.

  • On the server side, you can put additional limits by IP address or host name, but this is not really secure (IP adresses can be faked, for example). If the computers on which the application is to be run have already existing SSH installations, they should have host keys, and maybe you can do host authentication. But this is still only really useful if these hosts are under your control, more or less.

For security issues, a password (if you don't use a certificate) will always asked to you interactively, unless you configure server in an advanced way.

You can use a certificate, by inserting password one time.

Take a look at this

On debian, a tool exists for this and it's called sshpass (a noninteractive ssh password provider)

It comes with lots of warnings and caveats though! Be sure you assess the risks properly before continuing down this path...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top