I have a 2 node hadoop cluster.
I ran this command on the master:
$ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub [email protected]
How can I undo this? I would actually like to reassign the key.
192.168.1.1
is the slave.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityI have a 2 node hadoop cluster.
I ran this command on the master:
$ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub [email protected]
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 [email protected]
Edit the file ~hadoop/.ssh/authorized_keys
on 192.168.1.1
using your preferred editor, and delete the line containing your key.
ssh-rm-id [email protected]
ssh
to run a sed
command (or similar) to edit ~/.ssh/authorized_keys
and remove the line. See superuser.com/questions/429954/…
Apr 18, 2018 at 10:32
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.
ssh $remote "sed -i '\;$idssh;{d}' .ssh/authorized_keys"