-2

I have just installed Ubuntu 22.04.1 LTS on a Desktop Computer with previous Windows 10. Now I want to connect to my server with ssh, but I don`t want to enter each time the password for the private key. On Windows I used Pagent from PuTTY (or Kagent from Kitty) to hold my private key. On my MacBook I used this command in the Terminal (as root):

eval `ssh-agent -s` && /usr/bin/ssh-add -K /path/to/private/key

and in that Terminal's tab I could use ssh to my remote server after I entered once the password for the PK. But on Ubuntu 22.04 I dont know how to do it.

If I try as on MacOS, following the How-To from GitHub Docs, I get an error:

f@f-comp-ubuntu:~$ sudo -s -H
[15.38.20][root@f-comp-ubuntu:/home/f#eval "$(ssh-agent -s)"
Agent pid 33293
[15.38.52][root@f-comp-ubuntu:/home/f#ssh-add -K /my/key
Enter PIN for authenticator:
Provider "internal" returned failure -4
Unable to load resident keys: device not found

(My key is 600 and root:root)

How can I add my private key in the Terminal with ssh-add?

Thanks.frank

franc
  • 548
  • 5
  • 16

1 Answers1

0

I just ommitted the -K and it worked! So with:

eval `ssh-agent -s` && /usr/bin/ssh-add /path/to/private/key

it works without error. I found that in an answer from Rohan Patil to: 'Enter PIN for authenticator' Issue related to SSH I thought, the -K just means Key. And furhtermore, it is easier if the key is named id_rsa.

franc
  • 548
  • 5
  • 16
  • OK, it only seemed to work, but the key is not stored. When I connect to my ssh server again I have to enter the password for my key. Like this, the ssh-agent is of no use :( – franc Mar 11 '23 at 09:18
  • OK, I need to copy the first two lines of ssh-agent output and add then ssh-add (with the default ~/id_rsa key) then it works finally. – franc Mar 30 '23 at 10:07
  • In the end, I added the lines alias da='eval `ssh-agent` && ssh-add' into my bashrc and now it works. The problem is, that it is a different context, when run by a script and not in my terminals bash, where I need it (when I do ssh there). – franc May 18 '23 at 20:08