which gpg >/dev/null 2>&1 || return
export GPG_TTY=$(tty)
-gpg_import_host() {
+gpg_import_ssh() {
local usage="gpg_import_host HOST"
local host=${1:?$usage}
local tmp="/tmp/gpg_import_host.$USER"
- ssh -t "$host" 'GPG_TTY=$(tty) gpg --armor --export-secret-keys -o "'$tmp'"'
- ssh "$host" 'cat "'$tmp'" && rm "'$tmp'"' | gpg --import --allow-secret-key-import ~/
+ ssh -t "$host" 'install -m 600 /dev/null "'$tmp'" && GPG_TTY=$(tty) gpg --armor --export-secret-keys -o "'$tmp'"'
+ ssh "$host" 'cat "'$tmp'" && rm "'$tmp'"' | gpg --import --allow-secret-key-import
}