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
script:
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
[email protected]'s password:
terminal
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 protected]
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 [email protected] 'touch ~/test'
I am making the script executable and calling it with
./script
ssh -v
to print verbose debugging info. What's the difference? – Barmar May 20 '14 at 5:36#!/bin/bash
(shebang), but this wouldn't cause your problem. Do you have an alias forssh
? What is the output oftype ssh
? – Gilles May 20 '14 at 23:09