Linux – How to export the SSH’s public key

linuxpublic-keyssh

I need to set up ssh sessions between two servers and do not want to make the script fill in username and password everytime.

However I cannot seem to find out where the SSH server is using its config from.

bash-2.05# ssh -V
Sun_SSH_1.1, SSH protocols 1.5/2.0, OpenSSL 0x0090700f

I have certificate files file in both /etc/ssh/ and ~/.ssh/. I can only find one config file for SSH and it is in /etc/ssh/ssh_config, but it contains no data (everything is commented out).

Does anyone know how I can find out where the certificate is stored, or how I can export it so I can transfer it to the other server? I was hoping the config files would give me the answer, but they provide little to no help.

Best Answer

Assuming you mean public-key-authentication on a user-level by 'certificate' and you created them by using ssh-keygen with the default location, they should be at place where your ssh-client will find them. The key consists of a private part, usually stored in ~/.ssh/id_rsa and a public part in ~/.ssh/id_rsa.pub. The last one will have to be transferred to the remote server, usually to ~/.ssh/authorized_keys.

The easiest way to transfer the key to another server is using ssh-copy-id with the target machine. If you used the default location on creation, this key will automatically be used.

Note, that /etc/ssh/ssh_config is for the client. On the server you will have to look at /etc/ssh/sshd_config. In your setup both servers will serve as both ssh-client and ssh-server, so you would have to look at both files at both ends.