Which of the following commands can be used to remove an SSH key from the ~/.ssh/authorized_keys file on a remote server, revoking access to the corresponding user?Question 3Answera.ssh-keygen -R user@remote_hostb.grep -v "ssh-.*user@remote_host" ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmpc.ssh-keygen -f "~/.ssh/known_hosts" -R user@remote_hostd.sed -i '/^ssh-.*user@remote_host$/d' ~/.ssh/authorized_keys
Question
Which of the following commands can be used to remove an SSH key from the ~/.ssh/authorized_keys file on a remote server, revoking access to the corresponding user?Question 3Answera.ssh-keygen -R user@remote_hostb.grep -v "ssh-.*user@remote_host" ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmpc.ssh-keygen -f "~/.ssh/known_hosts" -R user@remote_hostd.sed -i '/^ssh-.*user@remote_host$/d' ~/.ssh/authorized_keys
Solution
The command that can be used to remove an SSH key from the ~/.ssh/authorized_keys file on a remote server, thus revoking access to the corresponding user, is:
b. grep -v "ssh-.*user@remote_host" ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp
This command works by using grep to search for lines that do not match the pattern "ssh-.*user@remote_host" in the authorized_keys file. The -v option inverts the matching, so lines that do not match the pattern are returned. The output is then redirected to a temporary file.
After running this command, you would then need to replace the original authorized_keys file with the temporary one. This can be done with the following command:
mv ~/.ssh/authorized_keys.tmp
Similar Questions
Which of the following commands can be used to copy an SSH public key to a remote server, allowing the owner of the corresponding private key to log in without a password?Question 13Answera.ssh-copy-id user@remote_hostb.ssh user@remote_host "echo $(cat ~/.ssh/id_rsa.pub) >> ~/.ssh/authorized_keys"c.scp ~/.ssh/id_rsa.pub user@remote_host:~/.ssh/authorized_keysd.echo "$(cat ~/.ssh/id_rsa.pub)" | ssh user@remote_host "cat >> ~/.ssh/authorized_keys"
Which of the following commands can be used to disable password-based authentication for an OpenSSH server on a Linux system, forcing all users to authenticate using an SSH key?Question 9Answera.sed -i 's/PasswordAuthentication yes/#PasswordAuthentication no/' /etc/ssh/sshd_configb.sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_configc.sed -i 's/#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_configd.sed -i 's/PasswordAuthentication no/#PasswordAuthentication yes/' /etc/ssh/sshd_config
Which of the following commands can be used to verify the authenticity of an SSH public key, ensuring that it belongs to the expected user?Select one:a.ssh-keygen -lf ~/.ssh/authorized_keysb.ssh-keyscan user@remote_hostc.ssh-keygen -lf ~/.ssh/id_rsa.pubd.ssh-keygen -lf ~/.ssh/known_hosts
You aim to disable password-based authentication in SSH and only allow key-based authentication for added security. What configuration change is needed in the SSH server configuration file?1.0 Marks. Set KeyAuthentication only in /etc/ssh/sshd_configSet PasswordAuthentication no in /etc/ssh/sshd_configSet UsePAM no in /etc/ssh/sshd_config
The ssh command option -p is used to specify __________.1 pointThe username for the remote serverThe path to the private key file to use for authenticationThe password for the SSH connectionThe port number to use for the SSH connection
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.