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

Adding ssh keys to a new server without having previously set up users on that server

· 52CE 我爱测

I've setup a clean new VPS running Ubuntu 20.04 LTS with Hetzner and would like to access it via ssh. Here is what I've tried to do: I have added my public ssh key (passphrase-less) in Hetzner's online GUI. That looked something …

问题原文

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

I've setup a clean new VPS running Ubuntu 20.04 LTS with Hetzner and would like to access it via ssh.

Here is what I've tried to do:

  1. I have added my public ssh key (passphrase-less) in Hetzner's online GUI. That looked something like this:
ssh-rsa blahblahblah= [email omitted]
  1. But when I attempt to ssh-copy-id this key to the server, I run into issues. Since I haven't logged into the server to create users, I don't know what to put for the user in this command:
ssh-copy-id -i .ssh/id_rsa_pub [user]@serveraddress

I've tried adding the key to root user like so:

ssh-copy-id -i .ssh/id_rsa_pub [user]@serveraddress

But then I'm prompted for a password I don't know.


This leads me to the following questions I've had a hard time finding answers to:

1. How can I use ssh-copy-id to copy my public key to the server if I haven't setup a user yet?

2. What is the default root password on the server? How Would I find this out? I've tried ubuntu, root, the basics.

3. What does adding a public key via GUI on the server host's website normally do with regards to server users? Does it add the key to the known_hosts file?

4. What is the technical significance of the final comment line in my public ssh key, currently [email omitted]?

已采纳解答

原帖链接 · Craig Miskell · CC BY-SA 4.0

  1. How can I use ssh-copy-id to copy my public key to the server if I haven't setup a user yet?

You'd need the password for the user, and for SSH to accept passwords (not always the case). I wouldn't expect this to be the way forward in this sort of situation, where the VPS provider has a copy of your public key.

  1. What is the default root password on the server? How Would I find this out? I've tried ubuntu, root, the basics.

There's nothing guaranteed; it will be defined by the VPS provider, and should be in their documentation.

  1. What does adding a public key via GUI on the server host's website normally do with regards to server users? Does it add the key to the known_hosts file?

Close; it would add it to the .ssh/authorized_keys file in some users' home directory. As you've identified, knowing which user is opaque

  1. What is the technical significance of the final comment line in my public ssh key, currently [email omitted]?

Nothing technical, it's just a label for human use.

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

资料来源与适用范围

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

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

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