Linux 4.4.0-34-generic #53-Ubuntu SMP Wed Jul 27 16:06:39 UTC 2016 x86_64 x86_64 x86_64 GNU/LinuxI use the script to start ssh-agent and start other script (which is using expect to sent passphrase to agent).#!/bin/basheval `ssh-agent -s`/root/script2/root/script2:#!/usr/bin/expect -fspawn ssh-add /root/.ssh/keyexpect Enter passphrase for /root/.ssh/key:send passphrase\n;interactAll scripts are +xPassphrase is valid 100%After starting first script I get:Agent pid 3985spawn ssh-add /root/.ssh/keyEnter passphrase for /root/.ssh/key:Identity added: /root/.ssh/key (/root/.ssh/key)As you see, agent started and Identity added BUT when I try ssh-add -l I get:Error connecting to agent: No such file or directoryBut process is still working with 3985 PID. Why it tells me Identity added but ssh-add -l didn't work? :(Ok, I try manually eval ssh-agent and add keyfile:root@:~# eval `ssh-agent -s`Agent pid 4063root@:~# ssh-add -lThe agent has no identities.root@:~# ssh-add /root/.ssh/keyEnter passphrase for /root/.ssh/key:Identity added: /root/.ssh/key (/root/.ssh/key)root@:~# ssh-add -l4096 SHA256:FxPiCFYOiRree0ogNPpo81DTDUqmr1Brlo0LFnFK12o /root/.ssh/key (RSA)Why it work when I try to run it manually? How to fix that?I want to add that to rc.local to autostart it when PC starts.UPDif I try to run only script2 manually, it works (key adds to agent).So I thing problem is with eval sh-agent, but I don't know what's wrong
How to automatically add keyfile and passphrase to ssh-agent?
linux;ssh;expect;ssh agent;rc