How To Install restricted-ssh-commands on Ubuntu 20.04
Introduction
In this tutorial we learn how to install restricted-ssh-commands
on Ubuntu 20.04.
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 Ubuntu 20.04. 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 update
After updating apt database, We can install restricted-ssh-commands
using apt-get
by running the following command:
sudo apt-get -y install restricted-ssh-commands
Install restricted-ssh-commands Using apt
Update apt database with apt
using the following command.
sudo apt update
After updating apt database, We can install restricted-ssh-commands
using apt
by running the following command:
sudo apt -y install restricted-ssh-commands
Install restricted-ssh-commands Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude
using the following command.
sudo aptitude update
After updating apt database, We can install restricted-ssh-commands
using aptitude
by running the following command:
sudo aptitude -y install restricted-ssh-commands
How To Uninstall restricted-ssh-commands on Ubuntu 20.04
To uninstall only the restricted-ssh-commands
package we can use the following command:
sudo apt-get remove restricted-ssh-commands
Uninstall restricted-ssh-commands And Its Dependencies
To uninstall restricted-ssh-commands
and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:
sudo apt-get -y autoremove restricted-ssh-commands
Remove restricted-ssh-commands Configurations and Data
To remove restricted-ssh-commands
configuration and data from Ubuntu 20.04 we can use the following command:
sudo apt-get -y purge restricted-ssh-commands
Remove 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-commands
References
Summary
In this tutorial we learn how to install restricted-ssh-commands
package on Ubuntu 20.04 using different package management tools: apt
, apt-get
and aptitude
.