Tuesday, June 17, 2014

How To Transfer Files between two Debian/Linux systems

How To Transfer Files between two Debian/Linux systems

OpenSSH is a well known program which allows you to login to a host remotely, and run commands etc.

It also comes with a simple file transfer system which can be used to transfer files securely.

SCP is the command to use. You can either transfer files to the remote machine from your local one, or vice versa.

Usage is Simple :

scp file-to-send user@host:/patch/to/place/file

For example to copy the interfaces files from your local machine (ariyano to a remote server called 'arbaaz' you could use:

ariyano@ariyano:~$ scp /etc/network/interfaces ariyano@arbaaz:
ariyano@arbaaz's password:

As no destination directory was specified the file will be transferred to your home directory upon the remote machine.

If you wish to transfer a lot of tiles you can copy a directory recurisvely, with the -r flag.
-----------------------------------------------------------------

WinSCP is a fantastic windows application you could use to drag & drop files over machines.
How To Configure NIC on Debian/Linux 
for DHCP or Static IP Configuration :

In any given case you might want to change an IP configuration on a Debian/Linux system to match your network, Or you might just want the DHCP lease to take over.

**** Below is an explanation of the configuration. If you want to jump directly to the configuration, scroll below to the bottom of the page marked Configuration STEPS :

Follow the steps below and you should be up and running in no time....

In order to configure your NIC, changes have to be made to a NIC configuration file on the system.

The File is called ( INTERFACES ) 
and is located at ( /etc/network/ )

In order to open the file and make changes to it, you need a TEXT editor, to save time you can use the default editor called (nano)

The command to open the interfaces file is :

nano /etc/network/interfaces

While in the Text editor. Follow the shortcuts below.

To erase a complete line of code = ctrl + k
To save your file                = ctrl + o and then press enter
To exit the editor               = ctrl + x
(if you have not saved your file prior exiting the editor, it will ask you do to so)

Case 1 : Configuring for DHCP lease, (default). This is the default in a new installed system.

**** By Default there are two interfaces. 1. The Loopback 2. The Actual Ethernet Interface

**** Leave the Loopback as it is and we will only make changes to the Ethernet interface.

**** Leave this config as it is if DHCP is required

----------------------------------------------------------------------------
# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
----------------------------------------------------------------------------
Case 2: Configuring a Static IP
Ex: 
IP 192.168.1.200
SM 255.255.255.0
GW 192.168.1.1
DNS 192.168.1.1

**** We will only make changes to the eth0 interface and leave the loop-back as it is

auto eth0
iface eth0 inet static = Tells the system to shift the NIC in static config mode on Ethernet0
address = The IP address you wish to configure
netmask = The Subnet Mask
gateway = The Gateway

Once done your interfaces file should look something like below.
Now you need to configure your DNS in order to resolve domain names.
Follow the steps under DNS Settings.

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

This file describes the network interfaces available on your system and how to activate them.

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1

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

DNS Settings: 

DNS setting are on a separate file all together. 

The file name is ( resolv.conf )

The file is located at : /etc/resolv.conf

To open the file type:
nano /etc/resolv.conf

----------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4
----------------------------------------

You might not see any entries in the file, if so, type in nameserver followed by the DNS IPs.
Each new line is a alternate DNS server.

Save the file and exit the editor.

Forcing the new IP changes to take effect without restarting the server.

1. Type the command below to bring down the eth0 interface

ifdown eth0

2. Tye the command below to bring up the eth0 interface

ifup eth0

To confirm your config, Type the command below.

ifconfig

Your config should look something like this, but it could differ from system to system depending on the number of Ethernet interfaces you would have.

--------------------------------------------------------------------------------------
eth0    Link encap:Ethernet  HWaddr 00:1e:4f:be:c2:47
          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:4fff:febe:c247/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1064060052 (1014.7 MiB)  TX bytes:824394600 (786.2 MiB)
          Interrupt:21 Memory:fe9e0000-fea00000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:297763 errors:0 dropped:0 overruns:0 frame:0
          TX packets:297763 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1233489069 (1.1 GiB)  TX bytes:1233489069 (1.1 GiB)
--------------------------------------------------------------------------------------

Configuration STEP :

1. Type ( nano /etc/network/interfaces )

2. Under ( # The primary network interface ) Type
    a. auto eth0
    b. iface eth0 inet static
    c. address xxx.xxx.xxx.xxx
    d. netmask xxx.xxx.xxx.xxx.xxx
    e. gateway xxx.xxx.xxx.xxx.xxx

3. Press ctrl+o and press enter to save and ctrl+x to exit the 
   editor

4. Type ( nano /etc/resolv.conf )

5. Type in your DNSs ( each new line is a alternate DNS server )
    a. nameserver xxx.xxx.xxx.xxx
    b. nameserver xxx.xxx.xxx.xxx

6. Presss ctrl+o and press enter to save and ctrl+x to exit the 
   editor

7. To bring down the interface
     a. ifdown eth0

8. To bring up the interface
     a. ifup eth0