我有一个 2 节点的 hadoop 集群。
我在主人上运行了这个命令:
$ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.1
Run Code Online (Sandbox Code Playgroud)
我怎样才能撤消这个?我实际上想重新分配密钥。
192.168.1.1 是奴隶。
Dav*_*rds 23
确定您在运行时复制的公钥ssh-copy-id:
cat ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)
通过 SSH 连接到您将密钥复制到的服务器:
ssh hadoop@192.168.1.1
Run Code Online (Sandbox Code Playgroud)
编辑文件~hadoop/.ssh/authorized_keys上192.168.1.1使用您喜欢的编辑器,并删除包含您的键线。
如果你做过ssh-copy-id类似的:
remote='user@machine'
ssh-copy-id -i $remote
Run Code Online (Sandbox Code Playgroud)
因此,您可以在不使用密码的情况下访问这台远程机器:
ssh $remote
Run Code Online (Sandbox Code Playgroud)
要以编程方式撤消它,您可以编写如下脚本:
idssh=$(awk '{print $2}' ~/.ssh/id_rsa.pub)
ssh $remote "sed -i '\#$idssh#d' .ssh/authorized_keys"
Run Code Online (Sandbox Code Playgroud)
我在需要scp多个文件的脚本中使用它,所以我只要求输入一次密码。
| 归档时间: |
|
| 查看次数: |
26337 次 |
| 最近记录: |