Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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 name@remotehost:~/
ssh name@remotehost ~/

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)

share|improve this answer
You beat me to it. I'll merge my (now deleted) answer into yours, please undo if you object. – RedGrittyBrick Dec 6 '12 at 11:06

You need to read about rhosts and rlogin.

share|improve this answer
Is this secure? It seems a sort of unencrypted remote shell. – gertvdijk Dec 6 '12 at 11:00

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 user@remotemachine.tld

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.