0

I am trying to deploy an executable and execute it on a remote Unix machine (Linux/Solaris) from Linux without entering the password manually.

I tried scp and also SSH key-gen utility to interact with remote server but in either way I couldn't avoid providing the password manually. Since I need to run this command/utility from Java code, I should completely avoid prompting for the password at run time. I have gone through many topics in Google but nothing has materialized.

How can I do this?

3 Answers 3

1

You should set up authentication using public/private keypair as you already mentioned you generated using ssh-keygen. Have it generated without a password on the private key if you need to use it in automated scripts. Now, just copy over the public key using ssh-copy-id name@host to set it up correctly on the remote side (authorize public key).

I suggest you to follow a tutorial like this one.

If ssh works, then scp works likewise.

After setting it up correctly, you should be able to do this without interaction:

scp myscript.sh name@remotehost:~/
ssh name@remotehost ~/myscript.sh

To avoid having to enter a password or passphrase there are a couple of choices

  • use an authentication agent to hold the password/passphrase for the private key
  • don't use any pass-phrase to protect the private key

The first is appropriate for interactive use, the latter is less secure. You should probably set up a new user-id for this with minimal rights at the far end (e.g. chrooted)

1
  • You beat me to it. I'll merge my (now deleted) answer into yours, please undo if you object. Dec 6, 2012 at 11:06
0

You need to read about rhosts and rlogin.

http://vegdave.wordpress.com/2007/05/17/how-to-rloginrcprsh-to-a-machine-without-enter-a-password/

1
  • Is this secure? It seems a sort of unencrypted remote shell.
    – gertvdijk
    Dec 6, 2012 at 11:00
0

Step 0. You must have ssh access to remote machine.

Step 1. Generate RSA private/public key pair with ssh-keygen on your Linux box and place it somewhere (/root/identities, for example). Provide no passphrase.

Step 2. ssh-copy-id -i /root/identities/your.key [email protected]

Step 3. This is it. Now you may ssh -i /root/identities/your.key user@remotemachine your_command and no password would be prompted. Sure, you must have PubkeyAuthentication = yes in remote machine's sshd_config.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .