Get to know your ssh-id
gpg -K, get key id- generate key with
gpg --export-ssh-key *key-id*!(symbol!after the key). The key is just for export, no need to add it anywhere in the system. No need to put it in the .ssh directory. Just for export to other server.
Export it to the server
Automatically
- export your ssh with the command:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@192.168.1.250
Manually
- or edit the file
~/.ssh/authorized_keysmanually, e.g.gpg --export-ssh-key *key-id!* >> ~/.ssh/authorized_keys - don’t forget to edit permission
chmod 700 /home/user_name/.ssh && chmod 600 /home/user_name/.ssh/authorized_keys - and give it to the user
chown -R username:username /home/username/.ssh
Set gpg-agent
- list keys with
gpg --list-keys --with-keygripand add the result with [A] to the file~/.gnupg/sshcontrol - add this code to
~/.zshrc:
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
As I get it that’s it.
Although, in Gentoo Documentation different code for .zshrc:
export GPG_TTY=$(tty)
if [[ -n "$SSH_CONNECTION" ]] ;then
export PINENTRY_USER_DATA="USE_CURSES=1"
fi