tl;dr No, but see The XY Problem.
$ strace -f ssh -i <(cat ~/.ssh/id_rsa) user@server echo test
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
So for some reason at the beginning
ssh closes the fd. Maybe it closes all but the standard descriptors.
In any case, your assumption is wrong:
Presumably ssh tries to access the fd several times, but the fd is destroyed after it has been read the very first time
There's just one syscall dealing with the fd before trying to
close(63). And yep, after that it gets destroyed.
agent. You would add the contents of your variable to the agent and ssh would get it from the agent. Therefore this answer on Stack Overflow is your solution
ssh-agentis usually part of ssh installations. If you have special constraints you should put them in your question, because we cannot guess those.