0

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

1 Answer 1

0

I added now an alias in my bashrc and with this it works without problem :)

alias da='eval `ssh-agent -s` && /usr/bin/ssh-add -K /Volumes/TC20GB/dickies/root/dickies.ssh' 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.