Ssh

ssh-copy-id 可以尊重我的 ssh 配置嗎?

  • April 6, 2022

我將所有密鑰儲存在外部,.ssh並配置了哪個密鑰用於我的.ssh/config. 我怎麼能ssh-copy-id尊重它?

除非有人想出一些未知的標誌,否則我將使用一個簡單的包裝器:

sshci() {
 ssh-copy-id -i "$(ssh -G "$1" | grep "^identityfile " | head -1 | cut -d " " -f2- | sed "s|^~|$HOME|")" "$1"
}

https://stackoverflow.com/questions/38304271/bash-extract-user-for-a-particular-host-from-ssh-config-file對創建這個有很大幫助:​​)

你可以試試:

ssh-copy-id -i {{the key you want to copy}} 
    {{the Host config name in ~/.ssh/config file}}

引用自:https://unix.stackexchange.com/questions/680990