a little ssh issue here.
I set up some keys in ssh between 2 machines and I can login via ssh without password in terminal.
I am trying to write a shell script that sends commands to the remote server through ssh. When i run the script it always asks for the ssh password before performing the commands. How can I make it so the ssh login in the script is passwordless like it is through terminal?
in the script it's like ssh user@remoteMachine 'do some stuff' the same command in terminal works perfectly fine.
(edit) verbose flag differences
debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/remote/.ssh/id_rsa debug1: Authentications that can continue: publickey,password debug1: Trying private key: /home/remote/.ssh/id_dsa debug1: Trying private key: /home/remote/.ssh/id_ecdsa debug1: Next authentication method: password firstname.lastname@example.org's password:
debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/remote/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). Authenticated to 192.168.1.4 ([192.168.1.4]:22). debug1: channel 0: new [client-session] debug1: Requesting email@example.com debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_GB.UTF-8 Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic i686)
the script is just
#/usr/bin/bash ssh firstname.lastname@example.org 'touch ~/test'
I am making the script executable and calling it with