I have a 2 node hadoop cluster.
I ran this command on the master:
$ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.1
How can I undo this? I would actually like to reassign the key.
192.168.1.1 is the slave.
I have a 2 node hadoop cluster.
I ran this command on the master:
$ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.1
How can I undo this? I would actually like to reassign the key.
192.168.1.1 is the slave.
Identify the public key that you copied when you ran ssh-copy-id:
cat ~/.ssh/id_rsa.pub
SSH to the server you copied the key to:
ssh hadoop@192.168.1.1
Edit the file ~hadoop/.ssh/authorized_keys on 192.168.1.1 using your preferred editor, and delete the line containing your key.
If you have done a ssh-copy-id like:
remote='user@machine'
ssh-copy-id -i $remote
So you can access this remote machine without using a password:
ssh $remote
To undo it programmatically, you can script something like:
idssh=$(awk '{print $2}' ~/.ssh/id_rsa.pub)
ssh $remote "sed -i '\#$idssh#d' .ssh/authorized_keys"
I use it in scripts I need to scp several files, so I ask only once for password.
AAA....== string (the actual key) or for the complete line from id_rsa.pub. But +1 for showing how to automate the removal of a key.
– PerlDuck
Jun 21 '18 at 09:57
ssh $remote "sed -i '\;$idssh;{d}' .ssh/authorized_keys"
– ccalvert
Oct 29 '19 at 22:11
'\#$idssh#d' instead.
– mle_ii
Aug 20 '20 at 17:10
ssh-rm-id hadoop@192.168.1.1– S.R Apr 18 '18 at 10:22sshto run asedcommand (or similar) to edit~/.ssh/authorized_keysand remove the line. See https://superuser.com/questions/429954/command-to-remove-a-ssh-authorized-key-on-server – David Edwards Apr 18 '18 at 10:32