INFORMATICS

The Best

Change SSH Port on CentOS

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Change SSH Port on CentOS 8
First, create a backup of sshd_config.
# cp/etc/ssh/sshd_config/etc/ssh/sshd_config_backup
Then open your ssh configuration to change it
# sudo nano /etc/ssh/sshd_config
This command will open the SSH (SSHD) server configuration.

We make the following change to the sshd_config file
# SSH port
Port 11111 # port that needs to be changed

 

We then update the IPTABLES firewall by introducing a new SSHD port.
If you have your firewall turned off, you can skip this step.
If you are using centos 6, you can run this command
For centOS 6
# iptables -I INPUT -p tcp --dport 11111 --syn -j ACCEPT
# service iptables save
# semanage port -a -t ssh_port_t -p tcp 11111
For centOS 7/8
# firewall-cmd --add-port 11111/tcp --permanent
# firewall-cmd --add-port 11111/tcp
The configuration will start working after restarting SSH Server (SSHD) services or after restarting the server.

# service sshd resrtart
or
# systemctl restart sshd

If you have trouble getting to SSHD, you need to configure SELinux policy since you changed port 22 to 11111.

Run this command.
# semanage port -a -t ssh_port_t -p tcp 11111
Then restart the server.
# reboot

 

Centos 8 install SSH service step by step

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Centos 8 install SSH service step by step
Install the openssh package:
# dnf install openssh-server
Start the OpenSSH service by executing the following command:
# systemctl start sshd
Check the status of the sshd service.
# systemctl status sshd
Enable the SSH service to start after the reboot:
# systemctl enable sshd
Open the firewall rules to accept incoming traffic on SSH default port 22:
# firewall-cmd --zone=public --permanent --add-service=ssh
Connect to the SSH server with IP eg. 10.1.1.1 as the root user from a remote client machine:
$ ssh This email address is being protected from spambots. You need JavaScript enabled to view it..6

httpd.service failed

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

centos  httpd.service failed

 

Test apache

apachectl configtest

[root@bis etc]# apachectl configtest
httpd: Syntax error on line 364 of /etc/httpd/conf/httpd.conf: Syntax error on line 202 of /etc/httpd/conf.d/virtuals.conf: /etc/httpd/conf.d/virtuals.conf:202: was not closed.

check virtuals.conf line xxx

 

Here is the output of systemctl status httpd.service

[root@bis log]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2019-10-18 15:12:00 CEST; 6min ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 11550 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 11548 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 11548 (code=exited, status=1/FAILURE)

Oct 18 15:12:00 b1s.eu systemd[1]: Starting The Apache HTTP Server...
Oct 18 15:12:00 b1s.eu httpd[11548]: httpd: Syntax error on line 364 of /etc/httpd/conf/httpd.conf: Synta...osed.
Oct 18 15:12:00 b1s.eu systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Oct 18 15:12:00 b1s.eu kill[11550]: kill: cannot find process ""
Oct 18 15:12:00 b1s.eu systemd[1]: httpd.service: control process exited, code=exited status=1
Oct 18 15:12:00 b1s.eu systemd[1]: Failed to start The Apache HTTP Server.
Oct 18 15:12:00 b1s.eu systemd[1]: Unit httpd.service entered failed state.
Oct 18 15:12:00 b1s.eu systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

 

 

Resest root password on CentOS 7

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Resest root password on CentOS 7

Start server, at the boot menu press e to edit the selected item

Finde the line with "ro"

remove ro and type rw init=/sysroot/bin/sh

Save changes -  CTRL + X

in single user mode type

chroot /sysroot

You can now change the password command:

passwd root

After creating the password, update SELinux parameters:

touch /.autorelabel

 

Search