Tag Archives: SSH

How To Recover A VPS Or Dedicated Server With Rescue Mode?

Rescue mode is a valuable tool for server administrators and system administrators because it provides a means to troubleshoot and recover a server in various scenarios.

Accessing your server by using the recovery console especially when you lose access to your Linux VPS or Dedicated Server is one thing. But, sometimes logging in through the recovery console doesn’t help or it doesn’t work for you then, in that case, you need to boot your server in ‘Rescue Mode‘.

In rescue mode, you are given temporary login credentials that you use to get into your server via SSH to resolve your server-related issues.

Login to your Sangkrit.net account and follow these steps:

  1. Visit your ‘Products‘ page
  2. On your ‘My Products‘ page, click ‘Manage
  3. Select ‘Rescue Mode‘ from the ‘Server Actions‘ option
  4. Click ‘Confirm

A progress message will appear, and in a few minutes, your server will reboot to rescue mode. Your server dashboard will now show that your server is running in ‘Rescue Mode‘. This message appears next to your server name.

Now you can use those temporary login credentials to access your server via SSH and you will be able to access all files available on your server.

Complete your work and when you are done, click ‘Exit Rescue Mode‘ present in your server’s Dashboard. Your server will now reboot to the active mode i.e. normal mode.

Additionally, exercise caution when making changes in rescue mode, as improper actions can potentially cause data loss or system instability.

How To Login To SSH Server Without Password?

SSH key authentication is a secure method of logging into an SSH server without needing to enter a password. It relies on the use of a pair of cryptographic keys: a private key (kept secret) and a public key (shared with the server). This lesson guides you on how to set up SSH key authentication and login to the server without password.

Generate SSH Key Pair

First, you need to generate an SSH key pair if you don’t already have one. Open your terminal and run the following command to generate a new SSH key pair:bashCopy codessh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa

-t rsa: Specifies the type of key to create (RSA).-b 2048: Sets the key length to 2048 bits (you can use higher values for stronger security).

-f ~/.ssh/id_rsa: Specifies the file name for the generated key pair (the default location is ~/.ssh/id_rsa).

During key generation, you can choose to set a passphrase for added security, but it’s optional. A passphrase adds an extra layer of protection to your private key.

Copy the Public Key to the Server

Next, you need to copy your public key to the server you want to access via SSH. You can do this manually or by using the ssh-copy-id command.

Replace <username> and <hostname> with your server’s username and hostname:bashCopy codessh-copy-id <username>@<hostname>

If you prefer to do it manually, you can append the contents of your public key (~/.ssh/id_rsa.pub) to the ~/.ssh/authorized_keys file on the remote server:bashCopy codecat ~/.ssh/id_rsa.pub | ssh <username>@<hostname> 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'

Make sure the ~/.ssh directory on the remote server has proper permissions (usually 700), and the ~/.ssh/authorized_keys file should have permissions set to 600.

Test SSH Key Authentication

You can now test SSH key authentication by attempting to SSH into the remote server:bashCopy codessh <username>@<hostname> If you set a passphrase for your private key, you’ll be prompted to enter it. Otherwise, you should be logged in without being asked for a password.

Disabling Password Authentication

For enhanced security, it’s a good practice to disable password-based authentication once you’ve confirmed that SSH key authentication is working. You can do this by modifying the SSH server’s configuration (typically located in /etc/ssh/sshd_config).

Set PasswordAuthentication to no.Reload the SSH server: sudo service ssh reload or sudo systemctl reload ssh.This ensures that SSH access can only be obtained using the authorized SSH key.

SSH key authentication is a secure and convenient way to access remote servers, and it’s widely used for server administration and secure file transfers. Just remember to protect your private key and use passphrases for added security.

The lesson guides you on the Linux server environment. If you’re using Windows, you can use an SSH client like PuTTY or Windows Subsystem for Linux (WSL) to follow similar steps.

How To Use Secure Shell SSH On Your VPS Or Dedicated Server?

Secure Shell (SSH) is a more secure and popular network protocol that delivers secure communication over an unsecured network, such as the Internet. SSH is primarily used for remote login and command-line execution on remote machines but it can also be used for securely transferring files from one system to another just like FTP. So in this case you can say that SSH is a more secure version of FTP.

After you subscribe to a VPS or Dedicated Server, you can transfer files and backup using SSH and for that, you will need to follow a few general steps to connect your server via SSH Secure Shell using a local client. This is needed to transfer, backup, or upload your web/app files, etc.

SSH is a cryptographic network protocol for operating network services securely. Since it is a method for doing a secure remote login from one device to another, here, the two devices are your local machine i.e. your computer, and your server i.e. your VPS or Dedicated Server.

Now following are the exact steps to make a connection via SSH but a few things may depend on the SSH client you use. If you don’t use Linux Terminal then you may use PuTTy for Windows, or Terminal on a MacOS machine.

​​Before you start with the SSH login you will need to obtain this info:

  • Your domain name or IP address
  • Your primary FTP username
  • Your primary FTP password

In case you don’t know where to find these things, you may search their tutorials or simply email or call the online support team to get help.

For security reasons, your dedicated server is provisioned with disabled admin/root access. But you can enable it by following these steps:

  1. Login to your Sangkrit.net account
  2. ​​Navigate to your My Products page
  3. Click Servers
  4. Next to the Generation 4 server, click Manage
  5. Select Settings from the top of the page in your account dashboard
  6. In the access section, next to the admin access, click Manage
  7. Select Enable Admin Access (this is actually root account sudo access) 
  8. Now click Save
  9. Admin access is now enabled

Next, Establish a connection:

Launch your SSH client, enter the host i.e. your domain name or IP address, and your SSH port number (which by default is 22) to establish the SSH connection.

Now you will be asked to enter the FTP details. As prompted for that, enter your primary FTP username and password and click GO or whatever action button is there in your client. That’s it. Your client will now make a connection.

Updating Nginx Server Configuration To Use The SSL You Have Purchased

You need to update the config file on your server to use the SSL certificate you are subscribed to. This can be done by accessing the command line SSH and opening the Nginx config file for the domain you are installing the SSL certificate.

Simply run the following command:

sudo vim /etc/nginx/sites-available/yourwebsite.com

Now update the config file to use the SSL certificate:

server {
        listen 80;
        server_name yourwebsite.com;
        return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;

    server_name yourwebsite.com;
    ssl_certificate     /etc/nginx/ssl/yourwebsite.crt;
    ssl_certificate_key /etc/nginx/ssl/yourwebsite.key;

    root /usr/share/nginx/yourwebsite.com/;
    index index.php  index.html index.htm;

}

The next step is to save the file using this command:

wq!

And then restart your Nginx server with this command:

sudo service nginx restart

That’s it.

Accessing The Recovery Console Of Linux VPS & Dedicated Server

In the previous lesson, you learned about the secure shell i.e. SSH. Next important thing is that if you lose access to your server due to some security issue, you can use the recovery console provided to you to regain access (via SSH) to your Linux VPS or Dedicated Server.

For example, in a case, if you have been accidentally locked out by some new firewall or IP rule then a recovery console is the thing you will need to regain access to your server. But there also you will need to know your server username and password so that you can connect to your server via SSH.

But before that, you should know while working on Linux VPS, some steps to regain access are different from the actual steps of the recovery console on the Dedicated Server.

So, If you are a VPS user simply follow these steps:

  1. Login to your SANGKRIT.net account and visit your Products page
  2. On your My Products page, click Servers, and next to the server you like to use, click Manage button
  3. Now in the top left corner of the Account Dashboard, select Recovery Console
  4. Next press Enter and now you can now log into your server to make changes

Whereas on a Dedicated Server, log in to your SANGKRIT.net account and follow these steps:

  1. Click the Servers option on your My Products page
  2. Click Manage right next to the Server you like to use
  3. On the top-right corner, click Server Actions
  4. Select Recovery Console

It takes a moment for the Recovery Console and then it automatically launches in a new browser tab. You will have to use your SSH login credentials to get into your server to make the required changes.

Now, the next important thing you should know is in case logging in through the Recovery Console does not work for you or it is of no help to you then, you should try booting your server in Rescue Mode. We will discuss the Server Rescue Mode in our next lesson.

Importing MySQL Databases Via SSH Command Line On Self Managed Servers

SANGKRIT.net not only offers you Managed and Fully Managed servers but it also lets you subscribe self-managed server option which is only recommended for command line experts. Because self-managed servers are without a control panel such as cPanel, Plesk, or Simple Control Panel.

These self-managed servers do not have phpMyAdmin installed which is used for managing MySQL databases. So in order to manage databases, you are required to use the SSH command line to import .SQL backup files.

This post guides you through importing MySQL databases via SSH.

Continue reading Importing MySQL Databases Via SSH Command Line On Self Managed Servers