0

Not sure the best to title this question... I have a bash script on Server A.

Work Ubuntu Desktop:

ssh -l USER host

*password*

coolscript var1 var2 var3

Server A (coolscript):

command1 $1

command2 $2

now at this point, I need to trigger coolscript2 on server b with the third argument passed. something like

run_remote_command_on_server_b coolscript2 $3

Server B (coolscript2)

command3 $3

However i need this to happen without having to enter user/pass for the second server.

1 Answer 1

2

If I understand your question correctly, you need to setup SSH keys.

Arch Linux Wiki has a great article on using SSH keys. You can also read shorter HOWTO here.

Basically, when you login from host A to host B via SSH, you can omit password authentication by generating private-public key pair. Private key is stored on the host A, and public key you copy to host B.

Please note, that there is an option to secure SSH private key with passphrase - in your case you wouldn't do that.

So, just generate keys on desktop:

$ ssh-keygen

Then copy them to Server A and Server B:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub HOST_A
$ ssh-copy-id -i ~/.ssh/id_rsa.pub HOST_B
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.