我将所有密钥存储在外部.ssh
,并配置哪个密钥用于我的.ssh/config
.我怎样才能ssh-copy-id
尊重这一点?
答案1
除非有人提出一些未知的标志,否则我将使用一个简单的包装器:
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-pspecial-host-from-ssh-config-file对创建这个有很大帮助:)
答案2
你可以尝试:
ssh-copy-id -i {{the key you want to copy}}
{{the Host config name in ~/.ssh/config file}}