大网数据广告活动
服务器运维问答

Why ssh doesn't find identity file while ssh-copy-id does?

· 52CE 我爱测

After renaming identity files id_ed2519_2(.pub) to id_ed2519(.pub) , ssh-copy-id can connect to remoteserver using file id_ed25519 (it asks for passphrase), while ssh can't, unless I add an identity file option (it asks for passp…

问题原文

原帖链接 · hello world · CC BY-SA 4.0

After renaming identity files id_ed2519_2(.pub) to id_ed2519(.pub), ssh-copy-id can connect to remoteserver using file id_ed25519 (it asks for passphrase), while ssh can't, unless I add an identity file option (it asks for passphrase) :

$ ssh-copy-id -n remoteserver  
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
Enter passphrase for key '/home/helloworld/.ssh/id_ed25519': 

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.

$ ssh remoteserver 
no such identity: /home/helloworld/.ssh/id_ed25519_2: No such file or directory
Permission denied (publickey).
$ ssh remoteserver -i ./ssh/id_ed25519 
Enter passphrase for key 'id_ed25519': 

How is that possible that ssh-copy-id happens to find the identity files id_ed25519 without IdentityFile option, while ssh continues to ask for non existing file id_ed25519_2 (even after rebooting server and client) ?

Obviously there must be some configuration file saying to ssh to look for id_ed25519_2. It is not in authorized_keys.

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

ssh-copy-id is a helper script, that unless otherwise restricted (with the -i <identity_file> option), actively looks for all ~/.ssh/*.pub public key files.

Without a similar -i <identity_file> option ssh on the other hand only looks for the default ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/id_rsa files.
If ssh looks for other files, that is because it is configured to do so in for instance a ~/.ssh/config file.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。