How To Install restricted-ssh-commands on Kali Linux
Introduction
In this tutorial we learn how to install restricted-ssh-commands on Kali Linux.
What is restricted-ssh-commands
restricted-ssh-commands is:
restricted-ssh-commands is intended to be called by SSH to restrict a user to only run specific commands. A list of allowed regular expressions can be configured in /etc/restricted-ssh-commands/. The requested command has to match at least one regular expression. Otherwise it will be rejected.
restricted-ssh-commands is useful to grant restricted access via SSH to do certain task. For example, it could allow a user to upload a Debian packages via scp and run reprepro processincoming.
Create a configuration file in /etc/restricted-ssh-commands/ and add following line to ~/.ssh/authorized_keys to use it
command="/usr/lib/restricted-ssh-commands",no-port-forwarding,
no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa [...]
There are three methods to install restricted-ssh-commands on Kali Linux. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.
Install restricted-ssh-commands Using apt-get
Update apt database with apt-get using the following command.
sudo apt-get updateAfter updating apt database, We can install restricted-ssh-commands using apt-get by running the following command:
sudo apt-get -y install restricted-ssh-commandsInstall restricted-ssh-commands Using apt
Update apt database with apt using the following command.
sudo apt updateAfter updating apt database, We can install restricted-ssh-commands using apt by running the following command:
sudo apt -y install restricted-ssh-commandsInstall restricted-ssh-commands Using aptitude
If you want to follow this method, you might need to install aptitude on Kali Linux first since aptitude is usually not installed by default on Kali Linux. Update apt database with aptitude using the following command.
sudo aptitude updateAfter updating apt database, We can install restricted-ssh-commands using aptitude by running the following command:
sudo aptitude -y install restricted-ssh-commandsHow To Uninstall restricted-ssh-commands on Kali Linux
To uninstall only the restricted-ssh-commands package we can use the following command:
sudo apt-get remove restricted-ssh-commandsUninstall restricted-ssh-commands And Its Dependencies
To uninstall restricted-ssh-commands and its dependencies that are no longer needed by Kali Linux, we can use the command below:
sudo apt-get -y autoremove restricted-ssh-commandsRemove restricted-ssh-commands Configurations and Data
To remove restricted-ssh-commands configuration and data from Kali Linux we can use the following command:
sudo apt-get -y purge restricted-ssh-commandsRemove restricted-ssh-commands configuration, data, and all of its dependencies
We can use the following command to remove restricted-ssh-commands configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge restricted-ssh-commandsDependencies
restricted-ssh-commands have the following dependencies:
References
Summary
In this tutorial we learn how to install restricted-ssh-commands package on Kali Linux using different package management tools: apt, apt-get and aptitude.