I have a Mac with macOS 10.11.6 and had the problem that when I connect through ssh to a server the password (for the private key) was not saved, I had to type it each login. So I found this solution here after this question:
"Mac OS X: keychain fails to save passphrase when connecting to remote host via ssh as root" and when I do that two commands:
eval `ssh-agent -s` /usr/bin/ssh-add -k /Volumes/path/to/my/ssh-key on the command line it works. Despite I get a "Could not create keychain item", the password is saved as long as I don't close the Terminal tab where I put those commands.
But when I put these two commands in a shell script and run it as the same user (root) as before, the key is forgotten at the next login. This is the simple script:
#!/bin/bash eval `ssh-agent -s` /usr/bin/ssh-add -k /Volumes/path/to/my/ssh-key I type the password and the SSH session opens, but after exiting it the password is gone, I have to type it again.
What is my error here possibly?
Thank frank