How to Allow root account to connect via SSH in FreeBSD

Posted on

As shown in the title of the article, the main focus in the article is explaining on how to allow root account to connect via SSH in FreeBSD operating system. In other words, the remote connection can be done using root account. Normally, it cannot be done by default even after fresh installation of FreeBSD has just finished. It is because normally by default the service which is responsible for handling the SSH connection will not allow¬† the SSH connection using ‘root’ account. It can be seen in the file configuration which is used to define how the SSH service behave where the file itself is located in ‘/etc/ssh/sshd_config’. There is a default entry describing the behavior of SSH service connection for not allowing the connection using ‘root’ account as shown in the line of configuration below :

#PermitRootLogin no

So, the line above is actually a default setting for SSH connection which is not allowing ‘root’ account to login remotely using SSH connection.

The steps taken for ‘root’ acccount can actually logging in to the FreeBSD-based operating system can be shown as follows :

  1. Login as ‘root’ locally.
  2. Open the configuration file representing the SSH service connection which is mentioned before, it is located in ‘/etc/ssh/sshd_config’.
  3. To enable or to allow ‘root’ account for connecting to the remote server of a server installed with FreeBSD, just add the following line of configuration :
PermitRootLogin yes

Another way it can be done is by uncommenting the line of configuration of ‘#PermitRootLogin no’, furthermore change the value into yes so in one way or another it will actually ends with line of configuration previously shown. It is ‘PermitRootLogin yes’.

4. Don’t forget to restart the SSH service so that the newly edited SSH configuration file can be included to define how the service SSH connection should behave. In this context, it allows ‘root’ account to connect using SSH connection.¬† It can be done by executing the following command in the command line :

service sshd restart

The example of the above command execution is shown below :

root@mybsd:~ # service sshd restart
Performing sanity check on sshd configuration.
Stopping sshd.
Performing sanity check on sshd configuration.
Starting sshd.
root@mybsd:~ #

One thought on “How to Allow root account to connect via SSH in FreeBSD

Leave a Reply