#start your ssh session like this ssh user@ip -X #then you can use the following command cat id_rsa.pub | xclip -sel clip
Here is what the above code is Doing:
1. It’s creating a new ssh key using the email as a label.
2. It’s starting the ssh-agent in the background.
3. It’s adding the ssh private key to the ssh-agent.
4. It’s copying the ssh public key to your clipboard.