我修改了用户授权 key 的位置,包括远离 /<user>/.ssh
的 root key 。至/abc/%u
。
[root@server]# grep AuthorizedKeysFile /etc/ssh/sshd_config
#AuthorizedKeysFile .ssh/authorized_keys
AuthorizedKeysFile /abc/%u
但是 ssh-copy-id 似乎不使用来自远程服务器的该信息,而是始终复制到“.ssh/authorized_keys”,如下面快照中的建议。有任何方法可以显式要求 ssh-copy-id 将 key 添加到指向的正确位置 /abc/%u
通过服务器上的 AuthorizedKeysFile?
root@client# ssh-copy-id root@server
Password: ********
Now try logging into the machine, with "ssh 'root@server'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
root@client#
谢谢!
最佳答案
使用 $HOME/.ssh/config 指定您正在运行的用户配置,并设置 IdentityFile 选项。 Nixcraft 在 [ http://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/] 上有一些很好的例子
关于linux - ssh-copy-id 不会复制到 sshd_config 中指定的自定义 'AuthorizedKeysFile',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31125671/