简体   繁体   English

如何自动将ssh公钥添加到authorized_keys文件?

[英]How to auto add your ssh public key to the authorized_keys files?

I am looking for the simplest set of commands you can run for adding your public key to the authorized_keys files of the root account on a remote server. 我正在寻找可以运行的最简单的命令集,用于将公钥添加到远程服务器上root帐户的authorized_keys文件中。

We assume that the current user has login access to the remote server and it is also listed in the sudoers file. 我们假设当前用户具有远程服务器的登录访问权限,并且它也列在sudoers文件中。

Running the command twice should have no effect. 两次运行命令应该没有任何效果。

How about running the ssh-copy-id command? 运行ssh-copy-id命令怎么样? Man pages says the following: 手册页说明如下:

ssh-copy-id - install your public key in a remote machine's authorized_keys ssh-copy-id - 将您的公钥安装在远程计算机的authorized_keys中

Sounds exactly what you're looking for? 听起来你正在寻找什么? I have never tried running the command twice, though. 不过,我从未尝试过两次运行命令。 It may not check for that. 它可能无法检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM