2

I want to transfer data between two Linux Ubuntu computers using just Ethernet cable and FTP software like gFtp

Is this possible? because i get connection refused when trying to connect

  • Yes. Its posible but you must have configured ftp on pc's. – 2707974 Jun 2 '14 at 11:38
  • what is the setting required how can i configure the FTP for this setting – user235244 Jun 2 '14 at 11:40
  • at least ftp port should be open, what OS do you use? – Ruslan Gerasimov Jun 2 '14 at 11:42
  • Ubuntu 12.04 and Ubuntu 14.04 – user235244 Jun 2 '14 at 11:43
  • 1
    You can find manual for ubuntu 12.04 here and for 14.04 here – 2707974 Jun 2 '14 at 12:15
3

In order to establish a connection between the two machines using an Ethernet cable, both machines need a static IP of which are on the same IP Subnet.

1. Grab an ethernet cable, and attach it to the primary machine's ethernet port, take the other side of the cable and plug it into the secondary machine's ethernet port.

2. Identify your ethernet interfaces on each computer, it should be either eth0 or something like enp3s0. Take note of those interface names because we're going to need them later. You can do this by simply entering, sudo ifconfig

3. On the primary machine... run this command in your terminal/command line: sudo ifconfig eth0 10.0.0.1 (replace eth0 with the primary machine's ethernet interface.)

4. On the secondary machine... run this command in its terminal/command line: sudo ifconfig eth0 10.0.0.2 (replace eth0 with the second machine's ethernet interface.)

5. Now... The two computers should be able to communicate with each other. You can test this by entering the command, on your primary machine, ping 10.0.0.2 -c 2 ... If you see "64 bytes from 10.0.0.2..." then the communication is working.

6. Connect to the secondary machine (IP Address: 10.0.0.2) using your FTP client... I'm assuming that you have already set up the FTP server on your secondary machine.

If these steps are unsuccessful please be sure to reply to me. The amazing part about this is the ability to configure a DHCP server to automatically assign an IP address to your secondary machine, but this is complicated.

  • 1
    To add: you need a crossover cable if you want to go directly from one machine to another, a normal ethernet cable won't do it. – Videonauth Nov 4 '17 at 3:30
0

And vsftp on my way

How to do it Install vsftpd and a PAM library Edit /etc/vsftpd.conf and /etc/pam.d/vsftpd Create user accouts with custom directories (in /var/www/ for example) Set directories with the correct chmod and chown Create a admin user with full access to the server Troubleshoot

  • Install vsftpd and libpam-pwdfile to create virtual users I wanted to create FTP users but I didn’t want to add local unix users (no shell access, no home directory and so on). A PAM will help you create virtual users.

    sudo apt-get install vsftpd libpam-pwdfile

  • Edit vsftpd.conf First you need to back up the original file

    sudo mv /etc/vsftpd.conf /etc/vsftpd.conf.bak

Then create a new one

sudo nano /etc/vsftpd.conf

Copy and paste the following lines. The file should ONLY contain these lines:

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
nopriv_user=vsftpd
virtual_use_local_privs=YES
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/$USER
chroot_local_user=YES
hide_ids=YES
guest_username=vsftpd
  • Register virtual users To register a user you use htpasswd, so I assume you have apache2 working on your server. Create a vsftpd folder then put configuration files in it.

    sudo mkdir /etc/vsftpd

then

`sudo htpasswd -cd /etc/vsftpd/ftpd.passwd user1`

-c means that we’ll create the file if it’s not existing yet -d forces MD5, you need it on ubuntu 12.04, just use it always The command will prompt for a password. If you want to add new users afterwards:

`sudo htpasswd -d /etc/vsftpd/ftpd.passwd user2`
  • Configure PAM in /etc/pam.d/vsftpd Again, you need to back up the orignal file

    sudo mv /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak

and create a new one

`sudo nano /etc/pam.d/vsftpd`

Copy and paste these 2 lines (this should be the only content). I insist only these 2 lines, I wasted a lot of time keeping the originals and just added these.

`auth required pam_pwdfile.so pwdfile /etc/vsftpd/ftpd.passwd`
`account required pam_permit.so`
  • Create a local user without shell access

    sudo useradd --home /home/vsftpd --gid nogroup -m --shell /bin/false vsftpd

You can check that it’s been created with the id command: id vsftpd. We define the user with the /bin/false shell because of the check_shell parameter (even if you don’t use it).

When the end user connects to the FTP server, they will be used for rights and ownership: chmod and chown. - Restart vsftpd The common way is using init.d like all deamon

`sudo /etc/init.d/vsftpd restart`
  • Create directories According to your configuration all users will be placed into this folder: /var/www/user1.

You need to create them with particular rights: the root folder cannot be writable!

/ [root = /var/www/user1] => 555
www [ /var/www/user1/www ] => 755
docs [ /var/www/user1/docs ] => 755

Note: the user cannot create files or folders in the root directory. In vsftpd.conf we have chroot_local_user=YES so the user can’t see anything outside of his folder. To him, the server looks like this:

So just run these commands:

mkdir /var/www/user1
chmod -w /var/www/user1
mkdir www/user1/www
chmod -R 755 /var/www/user1/www
chown -R vsftpd:nogroup /var/www/user1

The /var/www/user1 folder HAS TO exist or connection will fail.

Right now you can try to connect with your FTP client and it will succeed! If it doesn’t you can check the troubleshooting part.

  • Create an Admin user to access the entire server To create an admin user we need to register a new user with htpasswd.

Before we do so, I’ll advise you to check into the /etc/ftpusers file that define certain users that are not allowed to connect with ftp. I think it’s only for local users and not virtual users but just in case don’t choose a name contained in this file. Let’s be honest, vsftpd is complicated enough!

sudo htpasswd -d /etc/vsftpd/ftpd.passwd theadmin

Now we need to add a new line into /etc/vsftpd.conf

chroot_list_enable=YES

This means that your user will be placed into their folder (as a jail) EXCEPT users in the /etc/vsftpd.chroot_list

Let’s create this file and add our user, the file is a simple line containing “theadmin”. Add one user per line. That means you DON’T need to create a /var/www/theadmin folder, the user will login and start in /home/vsftpd.

Restart the server and you’re done !

Troubleshooting Here are some errors I encountered.

500 OOPS: vsftpd: refusing to run with writable root inside chroot ()

Your root directory is writable, this is not allowed.

500 OOPS: cannot change directory:`/var/www/theadmin` if the folder doesnt exist

The /var/www/$USER folder doesn’t exist, create it with the correct rights (not writable) or add the user into the /etc/vsftpd.chroot_list .

htpasswd: cannot create file /etc/vsftpd/ftpd.passwd The /etc/vsftpd/ folder has to be existing, htpasswd won’t create it.

vsftpd restart or stop error: “restart: Unknown instance“ This means you can’t start the deamon even if you have success message with /etc/init.d/vsftpd start.

0

On the computer you want to copy the data from

  1. Install the package openssh-server.
  2. Check the IP address (ip link addr or use the network indicator).

On the computer you want to copy the data to

  1. Install FileZilla (package: filezilla).
  2. Start FileZilla.
  3. Host: The IP address of the other computer prepended with sftp://. (Example: sftp://192.168.1.8)
    Username: The username you use to login on the other computer
    Password: The password you use to login on the other computer

  4. Press the Connect button.
  5. On the left you'll see the data on the computer you're running FileZilla from, on the right you'll see the remote computer. Just drag-and-drop from the right to the left panel (or in the other direction when necessary).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.