Image this, you are at your friend's house, and he has a hard disk full of data, that you would like to copy to your laptop.
But you only have a 4GB pen drive and copying the files between computers can be a tedious one. What if, you could just
connect the two computers using an ethernet cable and directly copy files through it? I am going to show you just that...
Things we need
1. Two Computers
2. An ethernet cable
3. An internet connection (for installing software)
4. Root access to both machines
Now, lets get started...
Lets name the computers 'A' and 'B'
In computer 'A', Install the package openssh on both systems using your package manager, in SUSE, doing "zypper install openssh" does not work, so do it through the YAST Interface
If you are using BroadBand, free the ethernet port of your computer by unplugging the ethernet cable of your modem.
Start "gnome-terminal" or any other terminal emulator by pressing "Alt + F2" and typing "gnome-terminal"
Become root, by typing the command "su" and entering the root password, to learn how to activate root in ubuntu, see here
type the command "ifconfig [interface] [IP] up". "Interface" can be 'eth0' or 'eth1', use 'eth1' if 'eth0' does not work
"IP" is the IP Address of your computer, for eg. 192.168.1.1, you can use any address you wish.
Now, let us start the service sshd, type the command "service sshd start", in terminal
In computer 'B', repeat all the steps done in computer 'A' but with a change in the IP Address. The IP Address of the two computers, should be different.
Now, go to the computer from which you want to transfer the files, let us say it is Computer 'B'
Let us first check, if the two computers are succesfully linked, type the following command followed by enter,
ping [IP of Computer 'A'], ie. if the IP Address of the computer 'A' is "192.168.1.1", the command would be "ping 192.168.1.1"
My output of the command is as follows
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=0.098 ms
64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=0.083 ms
64 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=0.078 ms
64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=0.080 ms
64 bytes from 192.168.1.1: icmp_req=5 ttl=64 time=0.064 ms
64 bytes from 192.168.1.1: icmp_req=6 ttl=64 time=0.075 ms
End the program by pressing "Ctrl + C"
If you got a similar output, then we have succeeded in what we have done so far...
Now, let us transfer a file from 'B' to 'A'
as root, type the command "scp [path_to_file] [user]@[IP]:[target_path]" where "path to file is the exact location of file you wish to transfer. "user" is the name of the user account, who will become the owner of the transfered file. Please note that, if you use "root" account, the file can only be accessed by root and you can't use a normal account to transfer files to location owned by "root"
"IP" is the IP Address of Computer 'A' and "target_path" is the exact location, where you wish the file to be saved. for example,
If computer 'B' have an IP Address of "192.168.1.1" and the user being "root" and the file to be transferred is "/file" and
the target location is "/root/file" the command will be "scp /file root@192.168.1.1:/root/file"
But, if you wish to transfer a whole folder of contents, you can add the switch "-r" to the command. Imagine I am moving a folder named "/folder" in Computer 'B' to a folder named "/root/folder", then the command would be:
"scp /folder root@192.168.1.1:/root/folder"
I am feeling a bit tired with all that typing, I hope this tutorial was not in vain...
But you only have a 4GB pen drive and copying the files between computers can be a tedious one. What if, you could just
connect the two computers using an ethernet cable and directly copy files through it? I am going to show you just that...
Things we need
1. Two Computers
2. An ethernet cable
3. An internet connection (for installing software)
4. Root access to both machines
Now, lets get started...
Lets name the computers 'A' and 'B'
In computer 'A', Install the package openssh on both systems using your package manager, in SUSE, doing "zypper install openssh" does not work, so do it through the YAST Interface
If you are using BroadBand, free the ethernet port of your computer by unplugging the ethernet cable of your modem.
Start "gnome-terminal" or any other terminal emulator by pressing "Alt + F2" and typing "gnome-terminal"
Become root, by typing the command "su" and entering the root password, to learn how to activate root in ubuntu, see here
type the command "ifconfig [interface] [IP] up". "Interface" can be 'eth0' or 'eth1', use 'eth1' if 'eth0' does not work
"IP" is the IP Address of your computer, for eg. 192.168.1.1, you can use any address you wish.
Now, let us start the service sshd, type the command "service sshd start", in terminal
In computer 'B', repeat all the steps done in computer 'A' but with a change in the IP Address. The IP Address of the two computers, should be different.
Now, go to the computer from which you want to transfer the files, let us say it is Computer 'B'
Let us first check, if the two computers are succesfully linked, type the following command followed by enter,
ping [IP of Computer 'A'], ie. if the IP Address of the computer 'A' is "192.168.1.1", the command would be "ping 192.168.1.1"
My output of the command is as follows
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=0.098 ms
64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=0.083 ms
64 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=0.078 ms
64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=0.080 ms
64 bytes from 192.168.1.1: icmp_req=5 ttl=64 time=0.064 ms
64 bytes from 192.168.1.1: icmp_req=6 ttl=64 time=0.075 ms
End the program by pressing "Ctrl + C"
If you got a similar output, then we have succeeded in what we have done so far...
Now, let us transfer a file from 'B' to 'A'
as root, type the command "scp [path_to_file] [user]@[IP]:[target_path]" where "path to file is the exact location of file you wish to transfer. "user" is the name of the user account, who will become the owner of the transfered file. Please note that, if you use "root" account, the file can only be accessed by root and you can't use a normal account to transfer files to location owned by "root"
"IP" is the IP Address of Computer 'A' and "target_path" is the exact location, where you wish the file to be saved. for example,
If computer 'B' have an IP Address of "192.168.1.1" and the user being "root" and the file to be transferred is "/file" and
the target location is "/root/file" the command will be "scp /file root@192.168.1.1:/root/file"
But, if you wish to transfer a whole folder of contents, you can add the switch "-r" to the command. Imagine I am moving a folder named "/folder" in Computer 'B' to a folder named "/root/folder", then the command would be:
"scp /folder root@192.168.1.1:/root/folder"
I am feeling a bit tired with all that typing, I hope this tutorial was not in vain...
No comments:
Post a Comment