Coders Tent

Server Admin's Diary

Changing the SSH port number

To change the port for the SSH server, follow these steps:

  1. Log in to the server as root using SSH.
  2. Open the /etc/ssh/sshd_config file in your preferred text editor (nano, vi, etc.).
  3. Locate the following line:
    Port 7822
    Remember that for security reasons, A2 Hosting uses port 7822 for SSH connections instead of the default port 22.
  4. Change 7822 to the new port number that you want to use.
  5. Save the changes to the /etc/ssh/sshd_config file, and then exit the text editor.
  6. Restart the SSH service using the appropriate command for your Linux distribution:
    • For CentOS and Fedora, type:
      service sshd restart
      
    • For Debian and Ubuntu, type:
      service ssh restart
      
  7. While still logged in as root, in a new terminal window try to log in using the new SSH port number. If the login fails, check your settings. Do not exit your open root session until you are able to log in using the new configuration.

How To Find and Edit php.ini File Using SSH

This is very simple way to find php.ini file to make changes. You need to have access to these files, and SSH login.

Step 1: To quickly find the file type:

php -i | grep 'Configuration File'

It will show you the location of the file. For most VPS servers, the file is located is /usr/local/lib.

Step 2: Enter the following command to change the directory:

cd /usr/local/lib

Step 3: You can use ls command to confirm the location. This command will display list of all the files and directories in the current location.

ls

Step 4: To edit the file:

pico php.ini

That’s all!

Move site https to http by .htaccess

# Redirect HTTPS to HTTP
# Canonical HTTPS/non-WWW

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

How to find a folder in Linux using the command line

You can use find and locate commands in Linux to find folders and files from the command line. This page shows how to search for folders in Linux using various command line utilities.

Command to find a folder in Linux

find command – Search for files and folder in a directory hierarchy
locate command – Find files and folders by name using prebuilt database/index

How to find folder on Linux using find command

The syntax is:
find /where/to/look/up/ criteria action
find /folder/path/to/look/up/ criteria action
find /folder/path/ -name “folder-name-here”
find /search/path/ -name “folder-name-here” -print
find /search/path/ -name “folder-name-here” -ls
find /folder/ -name “pattern”
Finding a folder named Documents

Example : find /home -name “phlox-pro”

To find a folder named “Documents” in your home directory ($HOME i.e. /home/vivek/ home directory), run:
find $HOME -type d -name “Documents”

OR
find ~ -type d -name “Documents”

OR
find /home/vivek/ -type d -name “Documents”

How to search for case incentive folder names

You can force find command interpret upper and lowercase letters as being the same. For example match Documents, DOCUMENTS, DocuMEnts and so on by passing the -iname option:
find $HOME -type d -iname “Documents”

OR
find ~ -type d -iname “Documents”

OR
find /home/vivek/ -type d -iname “Documents”

Reset SSH config from WHM?

There is, login to WHM using the non-SSL port 2086 and then change the URL to:

http://your-ip:2086/scripts2/doautofixer?autofix=safesshrestart

It makes your SSH configuration default.

How to to know SSH port on the cPanel server?

Steps to know SSH port of cPanel server –

1. Login to WHM with your login details.
2. Go to restart servicees.
3. Restart SSH server. Once service get restart you will get below information –
Waiting for “sshd” to restart ………waiting for “sshd” to initialize ………finished.
Service Status
sshd (/usr/sbin/sshd) running as root with PID 904715 (process table check method)
Startup Log
Starting sshd: [ OK ]
Log Messages
Apr 6 05:48:40 server sshd[904715]: Server listening on :: port 8872.
Apr 6 05:48:40 server sshd[904715]: Server listening on 0.0.0.0 port 8872.
Apr 6 05:48:39 server sshd[4031]: Received signal 15; terminating.
sshd restarted successfully.
That’s it!

In the above output, you can see 8872 is the SSH port.

Missing DEFMOD Config Line in /etc/wwwacct.conf

1. Login as root
2. Type “pico /etc/wwwact.conf”
3. Add the following line “DEFMOD Xskin” (replace Xskin with the default theme).

or

Use

1. Login as root
2. Type nano /etc/wwwact.conf
3. Add the following line “DEFMOD Xskin” (replace Xskin with the default theme).

How to increase the PHP Max Input Vars

The PHP Max Input Vars is the maximum number of variables your server can use for a single function. To work properly with a modern WordPress theme set this value to 5000. Lower values can create problems such lost data in your Theme Options, Widgets disappear etc.

How to increase the PHP Max Input Vars

Like the other values above, you’ll need to access and modify either the php.ini or the .htaccess files. Most hosts won’t grant you full access to modify the PHP.ini file because it affects the whole server and all the websites hosted on it.Please contact your host first to find out if they can adjust it for you.

For advanced users who have their own server setups and full access to the php.ini file, please go ahead and try Method 1 first before the other method. For standard users, we encourage you to try Method 2 instead.

1. Method: edit the PHP.ini file

NOTE: many shared hosts prohibit you from having direct access to the PHP.ini file. Only do this method if you have direct access to your PHP.ini file or if you’re on your localhost.

  1. Locate your PHP.ini file. If you can’t find it, then you can create your own PHP.ini file in the root folder of your WordPress installation.
  2. If you find your existing PHP.ini, open the file and locate the following line of code (xx represents a number):max_input_vars = xx; And set it to your desired limit. For example, 5000.
  3. If you created your own PHP.ini file, then add the same code inside it:max_input_vars = 5000 Simply change the value to the recommended value. For example, 5000.
  4. Save your changes, and reboot your localhost or your server.

2. Method: edit the .HTACCESS file

NOTE: make sure to backup your .htaccess file before editing.

  1. Locate your .htaccess file which is usually in the root folder of your WordPress installation. If you can’t find it, it may be because it’s hidden. Here’s a tutorial for Windows and a tutorial for Mac on how to reveal hidden files on your computer.
  2. Open the .htaccess file with a text editor program (Notepad or TextEdit) and add the following line of code:php_value max_input_vars 5000. Simply change the value to the recommended value. For example, 300.
  3. Save the file and refresh your website.

Suhosin

This issue is less common, nowadays, but the issue can also occur due to a program called Suhosin which runs on your server. This is a known issue with WordPress and affects both the standard WordPress Menu System.

In most cases, the solution is as simple as asking your host to increase the max_vars variables in your php.ini.

suhosin.post.max_vars = 5000 
suhosin.request.max_vars = 5000  

Know Linux Name and Version

The procedure to find os name and version on Linux:

  1. Open the terminal application (bash shell)
  2. For remote server login using the ssh: ssh user@server-name
  3. Type any one of the following command to find os name and version in Linux:
    $cat /etc/os-release
    $lsb_release -a
    $hostnamectl
  4. Type the following command to find Linux kernel version:
    $uname -r

/etc/issue file

Use more command/less command as follows:
$ cat /etc/issue
$ more /etc/issue
$ less /etc/issue

Getting help

You can also view the manual page on uname using the following command:
$ man hostnamectl
$ man uname
$ man cat

Transfer SSL certificate with cPanel/WHM

In this article, we are going to see how we can migrate SSL certificates from one server to another. Before we transfer, you should be aware of the components involved with SSL certificates and how it is stored. Let’s have a detailed look on it.

There will be a certificate file. It will have the extension (.crt). Also, there will be a key and it will have the extension (.key). There will also be a CA bundle. We need to copy the files to new server in order to migrate the SSL certificate.

Steps to transfer SSL certificate

1) Login to your WHM.

You could access the WHM with https://server.hostname.tld:2087. This will lead you to the home page of WHM interface.

Now locate the ‘SSL/TLS’ section in WHM and go to ‘SSL Storage Manager’ as shown in the figure.

You will be lead to the next page. There you could find the certificates and keys with the username. Please locate the certificate you wish to transfer.

2) Copy the key

Please refer to the attached screen shot for any clarification.

Now you need to copy the key and paste it on a text file. To view the full content, please click on the lens icon near the key. The key will be starting with —–BEGIN RSA PRIVATE KEY—– and will end up with —–END RSA PRIVATE KEY—–.

3) Copy the Certificate

Now you need to copy the certificate. This also can be done from the previous window. Please click on the lens icon next to the certificate so that you would be able to view and copy the certificate.

Please copy and paste the certificate on a text file. The certificate will be starting with —–BEGIN CERTIFICATE—– and ending with —–END CERTIFICATE—–.

Now you need to install the certificate on the new server. You could install it from the WHM interface and the cPanel interface.

4) Install the certificate on new server

To install the certificate from the WHM, please locate “Install an SSL Certificate on a Domain” under the “SSL/TLS”. Please refer to the screenshot below in case of any doubts.

You need to use the certificate and key copied and saved on the text files earlier. You also could install it from the cPanel interface. To see how to install SSL certificate from the cPanel interface, please follow the guide in the link below.

If you need any further assistance please contact Syed Ashik Mahmud

« Older posts