save ssh public key with ssh-copy-id to server

mattiamueggler
mattiamueggler
Community Member
edited May 18 in SSH

I generated a ssh-key with 1Password. How can I save the public key to my remote Linux VM? If I enter this: ssh-add -L I get several keys which are stored in my 1Password. How can I choose one of these to store this one on my remote Linux server? Which path do I need to enter in ssh-copy-id -i "/path/to/file" username@host"? If I enter ssh -o IdentitiesOnly=yes username@host I can access my server, but I have to type my server password every time.

If I only run ssh-copy-id username@host I'm going to get:

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 9 key(s) remain to be installed -- if you are prompted now it is to install the new keys

I did every step, which is here described:
https://developer.1password.com/docs/ssh/get-started/

I also set this environment variable:
SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"

I did everything that is here described:
https://1password.community/discussion/127296/ssh-copy-id-functionality
I created a directory and file, gave both of them the right permission, and then typed this command: ssh my-username@my-host "echo $(ssh-add -L | grep "$MY_1PASSWORD_SSH_KEY_NAME\$") >> ~/.ssh/authorized_keys"

Do you have any ideas on how I can access my Linux server with an ssh-key?


1Password Version: 8.10.32
Extension Version: 2.23.3
OS Version: macOS 14.4.1
Browser: Arc 1.42.1

Comments

  • mattiamueggler
    mattiamueggler
    Community Member

    I couldn't solve my problem, but I've found a workaround. I created a ssh-key-pair in bash and imported this key to 1Password instead of generating a key directly in 1Password.

  • Michael Mercurio
    Michael Mercurio
    Community Member

    When I'm using ssh keys managed with 1Password, I store the public key files in my ~/.ssh directory and reference the public keys in ~/.ssh/config. For example, ~/.ssh/id_ed25519.pub.

    If you did this, I think could you copy the public key file using ssh-copy-id (I haven't tried it.) Either way, I really like the idea of my private keys not being stored on disk and only in my encrypted 1Password vault.

This discussion has been closed.