Showing posts with label openssh-server. Show all posts
Showing posts with label openssh-server. Show all posts

Thursday, March 15, 2018

Making the backup process simple and automatic

Let's we have two Ubuntu servers:

Server-1: IP: 1.2.3.10 (source server )
                 user account name: user1
                 user account password: user1
                
Server-2: IP: 1.2.3.11 (Destination server)

--------------------------------------------------

On Server-1
1. Install openssh-server. You may install through terminal.
2. configure openssh-server if needed, else leave it to the default configuration.

On Server-2
1.  Install openssh-server and sshpass through the terminal.
2.  Change the current directory to $USER/Desktop/backup
3.  Create the directory "data"
3.  Create a password file "pw.txt" with following content.
"pw.txt" content
user1
 4.  Create a shell script file with the name "backup.sh" with following content.
backup.sh content
sshpass -f pw.txt scp -r user1@1.2.3.10:data/*  /home/server2/backup/data/

5.  Make sure pw.txt and backup.sh files are in the same directory.
6.  Execute following command in the terminal
    bash backup.sh
   This  will copy all the content from user1@1.2.3.10:data/ path on Server-1 to /home/server2/backup/data/ directory on Server-2.

--------------------------------------------------

Now its time to schedule the bash backup.sh command to execute in a specific time interval

Make sure you have gone thorugh crontab manual page or gnome-schedule GUI. You may also go through this page to know more details on crontab and gnome-schedule.

1.  Open terminal
2.  Enter following command
crontab -e
3. If you are executing this command for the first time, it will ask for the choice to open an editor.
4. In the editor add following line at the end of the file.
0,12 * * * * bash /home/server2/backup/backup.sh
5. Save and exit the editor.

You can also use gnome-schedule command to schedule the "backup.sh"


-Thats all



Saturday, June 10, 2017

X11 forwarding using Xming X server for Windows

Problem statement:

Let's say, We have 2 two computers: One with Ubuntu OS and other with Windows OS
Through SSH connection, "How can we access the any application's interface (GUI) installed on Ubuntu computer from Windows computer ?". For example, we want to access the GUI of calculator application that is installed on Ubuntu from Windows computer.

Environment:

First computer:
                       OS- Ubuntu 14.04 64-bit
                       Openssh-server package
Second computer:
                       OS- Windows 8 64bit
                        Xming software tool

Here, for demonstration, we will open GUI of calculator application
The command to open the calculator in Ubuntu is gnome-calculator                      

Step-1:
On Ubuntu Computer, install openssh-server package.

Perform Step-2 to 5 on Windows computer.
Step-2:
On Windows computer: 
Download Xming for Windows 8 64bit.
Install Xming executable file. You don't have to do any changes. Leave everything to the default selection.

Step-3: 
Now open command prompt on Windows computer
Change the directory to the location where Xming is installed. In my case it is "C:\Program Files (x86)\Xming"


cd "c:\Program Files (x86)\Xming"

Step-4:
Now enter the following command to start Xming on Windows


Xming.exe -multiwindow -clipboard


Step-5:
Now its the time to connect to the Ubuntu computer through inbuilt putty. In this step, you need to provide the login information, and the command to open required application.

The command can be

plink -ssh -2 -X user1@<IP of ubuntu computer> -P <port number of SSH server> <command to open the required application>



e.g.

plink -ssh -2 -X chinmaya@120.162.56.85  -P 23 gnome-calculator


Here, I am connecting to the Ubuntu computer through ssh protocol 2.
The IP address and SSH port number of Ubuntu computer is 120.162.56.85 and 23, respectively.
gnome-calculator is the command to open the GUI of calculator application.

After entering the above command, you need to give the corresponding password. If all goes well, the required GUI will appear on Wondows computer.

Please comment if you need more information or if you have any suggestion.

-Thank you