How To Operate All Your VPS From 1 VPS (Linux)
The main reason why I created this thread is because I have 50 VPS and I find it too hard to open 1 VPS from Putty and configure it and open another VPS and configure it and it goes on for the rest 48 VPS.
So I decided to find a way where I can input one command from 1 VPS which will execute on the rest 50 VPS. And I finally found a way that works pretty awesome.
Requirement:
- More than 5-10 VP
- Putty software
- SSH connection
- Little knowledge about Linux
This post might by little hard for 1st time you try but 2nd time its gonna be easy. Well lets get started.
In this tutorial I will show you how do I operate 4 VPS with 1 VPS. You can have infinite number VPS connected to your main VPS. Your main VPS doesn't need extra RAM or STORAGE SPACE.
Creating SSH Key:
- Download Putty and run it. Add your VPS IP and connect to your VPS though Putty. After that enter "username" and "password".
- Now type on your main computer to generate a SSH key:
ssh-keygen
- Just press "Enter" button. This is an optional passphrase that can be used to encrypt the private key file on disk
- Your will get some thing like this:
Generating public/private rsa key pair. Enter file in which to save the key (/home/username/.ssh/id_rsa): - If you had previously generated an SSH key pair, you may see a prompt that looks like this:
/home/username/.ssh/id_rsa already exists. Overwrite (y/n)?Be very careful when selecting yes, as this is a destructive process that cannot be reversed. - Once you have pressed "Enter" button you will see something like this:
Your identification has been saved in /home/username/.ssh/id_rsa. Your public key has been saved in /home/username/.ssh/id_rsa.pub. The key fingerprint is: a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90:26 username@host_ip_2 The key's randomart image is: +--[ RSA 2048]----+ | ..o | | E o= . | | o. o | | .. | | ..S | | o o. | | =o.+. | |. =++.. | |o=++. | +-----------------+
Now have a public and private key that you can use to authenticate. The next step is to do the same step again from 1st-6th on rest of the 4 VPS.
For this method to work, you must already have password-based SSH access to your 4 VPS.
Type this command on your 1st VPS:
You may see a message like this:
Type "yes" and press ENTER to continue.
Next it will ask your "host_ip_2" password (Which means enter your 2nd VPS password):
Once done you will see output that looks like this:
Now you can connect your VPS 2 from VPS 1. All you need to do now is just copy public key using ssh-copy-id for your rest of the VPS ( VPS 3, VPS 4, VPS 5 to your main VPS which is VPS 1).
To disable SSH timeout checkout: https://docs.oseems.com/general/application/ssh/disable-timeout
Sorry for bad English. I hope you enjoy this tutorial.
Copying Public Key Using ssh-copy-id:
Once done now open your 1st VPS which is going to be the main VPS that is gonna control your 4 VPS. Now you have to copy your 4 VPS Public Key Using SSH-Copy-ID to your main VPS. It's simple don't panic.For this method to work, you must already have password-based SSH access to your 4 VPS.
Type this command on your 1st VPS:
ssh-copy-id username@host_ip_vps2
You may see a message like this:
The authenticity of host 'host_ip_2 (host_ip_2)' can't be established. ECDSA key fingerprint is fd:fd:d4:f9:77:fe:73:84:e1:55:00:ad:d6:6d:22:fe. Are you sure you want to continue connecting (yes/no)? yes
Type "yes" and press ENTER to continue.
Next it will ask your "host_ip_2" password (Which means enter your 2nd VPS password):
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys username@host_ip_2's password:
Once done you will see output that looks like this:
Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'username@host_ip_2'" and check to make sure that only the key(s) you wanted were added.
Now you can connect your VPS 2 from VPS 1. All you need to do now is just copy public key using ssh-copy-id for your rest of the VPS ( VPS 3, VPS 4, VPS 5 to your main VPS which is VPS 1).
Command to execute commands from 1st VPS (MAIN):
Your almost done! Now what you have to do is open your VPS 1 and then type this command:for ip in host_ip_2 host_ip_3 host_ip_4 host_ip_5; do ssh root@$ip 'echo hello'; done
The above code will type "hello" in 4 of your VPS. So using this command your can update(apt-get update), upgrade(apt-get upgrade) and execute almost all the commands from 1 VPS.To disable SSH timeout checkout: https://docs.oseems.com/general/application/ssh/disable-timeout
Sorry for bad English. I hope you enjoy this tutorial.
How To Operate All Your VPS From 1 VPS (Linux)
Reviewed by N Tips
on
6/22/2016
Rating:
No comments: