Предположительно ssh
пытается получить доступ к fd
несколько раз, но fd
уничтожается после это было прочитано в самый первый раз:
# ssh -i <(echo $KEY) user@example.com
Warning: Identity file /dev/fd/11 not accessible: Bad file descriptor.
user@example.com: Permission denied (publickey).
Есть ли другой способ без записи/удаления временного файла?
export MYKEY=`cat key.pem`
ssh-add - <<< "$MYKEY"
ssh ec2-user@100.123.111.63
tl;dr Нет, но см. Проблема XY .
$ strace -f ssh -i <(cat ~/.ssh/id_rsa) user@server echo test
...
close(63)
...
newfstatat(AT_FDCWD, "/dev/fd/63", 0x7ffc4f1d0c60, 0) = -1 ENOENT (No such file or directory)
write(2, "Warning: Identity file /dev/fd/6"..., 77Warning: Identity file /dev/fd/63 not accessible: No such file or directory.) = 77
Так почему-то в начале ssh
закрывает фд. Может быть, он закрывает все, кроме стандартных дескрипторов.
В любом случае ваше предположение неверно:
Presumably ssh tries to access the fd several times, but the fd is destroyed after it has been read the very first time
Есть только один системный вызов, работающий с fd перед попыткой stat
его:close(63)
. И да, после этого он уничтожается.