Ubuntu Remote tool- Part2 Transfer files

CC(ChenChih)
Chen-Chih’s Portfolio Page
23 min readJan 22, 2023

Last time I posted an article about the Remote tool which is based on remote access from the server to client, or client to client. I know it takes long time I write this post. Today I am showing you how to transfer files or data which is also part of the remote tool.

There’re many related transfer tools, I will pick the tool I use often, which is also regardless easy and free to use. Transferring tool is not using how professional this tool is, it is to help you establish your goal. You can think the easiest setup time to achieve your goal = is productive, which is what I aimed for.

Today I am going to mention these transfer tools:

SCP

FTP

TFTP

SAMBA

NFS

CURL

WGET

Structure of my post:

1. SCP
- 1.1 Setup SSH install the SSH package in Ubuntu
- 1.2 Configuring an SSH login without a password
- 1.3 SCP to transfer file upload or download
- 1.3.1 Linux command
- 1.3.1–1 Upload and Download File
- 1.3.1–2 Upload and Download Folder
- 1.3.2 window method
- 1.3.2–1 using the window command to upload or download
- 1.3.3–2third-party tool without typing cli command
- Terateam- method1 drag file
- terateam-method2 use ssh scp
- 1.4 automation script for SCP
2. FTP
- 2.1 Setup FTP Server (vsftpd)
- 2.2 set configuration for account:
- 2.2.1 Anonymous account without password
- 2.2.2 login with FTP account with a password
- Upload file occur 550 and 553 ERROR MSG solution
- 2.3 FTP command for upload and download
- 2.4 Advance FTP setting (option)
- 2.5 add firewall on port
- 2.6 add userlist manage FTP user
- 2.7 Deny FTP user to access ssh
- 2.8 Secure FTP with TLS
- 2.9 Upload to a Web Server
- 2.10 window (thirty-party tool)
3. TFTP
- Setup tftpserver unbuntu
- Window third-party tool
4. SAMBA
- Window setup samba(window server access window client)
- Linux access window samba
5. NFS
- setup NFS server
- NFS client
- Ubuntu
- window
6. CURL
7. WGET
8. conclusion

1. SCP(SSH)

SCP use the SSH method to upload or download file, but in order to use the SCP command we need to set up SSH, so I will show you how to set up SSH.

For people who have no idea what’s SSH, basely you can refer it as remote to Linux server, by using the command line. It’s pretty important and used often if you’re using Linux. SSH and telnet seem alike, but ssh has another powerful tool which is SCP to upload and download a file from local to remote or remote to local. I hope my description is clear about what’s is SSH, if not clear you can find more detail on the internet.

1.1 Setup SSH install the SSH package in Ubuntu

  1. Install package openssh-server (in case you haven’t had ssh installed)

$sudo apt install openssh-server

Note: SSH server(current PC) mean ssh client is able to access to your server, so in order for people to remote access you need to install ssh server.

2. check ssh service status

$sudo systemctl status ssh

If not enabled, please use this command:

shutdown or enable ssh services

$sudo systemctl disable — now ssh

$sudo systemctl enable — now ssh

3.check ssh command work or not, ex:$ssh

When it’s been installed you can type SSH command to see if it works or not. It should be able to work since we already install it.

4. adding a firewall (option)

It’s an option, you don’t have to set this if you don’t like it.

$sudo ufw allow ssh

5. login into the server

You can use many different ways to achieve it, by a Linux command line, or a third-party tool such as putty, terateam, winscp, and many more free open-source tools.

  • Window (third-party tool) using putty or terteam
  • Linux connects to the server: $ssh username@server_IP_Address

1.2 Configuring an SSH login without a password

SSH Server : 192.168.0.12

SSH Remote Host : 192.168.0.11

1. Create Authentication SSH-Keygen Keys on — (192.168.0.12)

$ ssh-keygen -t rsa

2. Upload SSH Key to — 192.168.0.11

Use SSH from server 192.168.0.12 and upload a new generated public key (id_rsa.pub) on server 192.168.0.11 under username.ssh directory as a file name authorized_keys.

$ ssh-copy-id username@192.168.0.11

I have written another post on SSH without the password method, there’re many easier ways to achieve it, so I’m not going to waste time talking about it.

Now after understand the fundamental of SSH, it time to go to SCP this command for upload or download file.

1.3 SCP to transfer file upload or download

I’m going to show you two methods to do it now with command, one with third-party in case some people don’t like to remember the command.

  • 1.3.1 Linux command

show directory:

syntax:

Download : scp <remote-username>@<hostname or IP>:<file/direcotry> username password

Upload : scp <file/direcotry> <remote-username>@<hostname or IP>username password

1.3.1–1 Upload and Download File

Upload File: $scp d:\share\test.txt test@192.168.50.83:/home/test

Download File: $scp test@192.168.50.83:/home/test d:\share\test.txt

1.3.1–2 Upload and Download Folder

Scp transfer directory/folder using: scp -r , r is recursive

scp -r d:\share\python-scan-port test@192.168.50.83:/home/test

  • 1.3.2 window method

1.3.2–1 using the window command to upload or download

window has pscp the command you can use to upload to the Linux server

$pscp window-source test@hostip:/linux-destination

1.3.3–2third-party tool without typing cli command

  • Terateam- method1 drag file

- terateam-method2 use ssh scp

you can also use WinSCP, which allows you to access to Linux directory just like Filizila you can drag the left local window, and the right one is linux server.

So there are many options for the tool you want to use you can decide which to use. I only use terateam, putty, and WinSCP, but there are many more third-party tools you can use.

1.4 Automation (bash)

I would like to share how to write SCP automation when transferring file/s. So why automation, because of passwords, and command line to remember, which is tedious.

I am showing the easiest way to achieve it, which I used often. In the future, I will write some bash script automation notes.

Below I am showing you the automation script, but before that, let look at the topology, for people who don’t know what are upload and download, this is a diagram :

UPLOAD: local(source) ->server(destination)

DOWNLOAD: local(destionation) ->server(source)

Exampl1: download and Upload a file from the server to local

The user will ask you to type Source and Destination file location.

instead of using the long command:

scp username@hostIP:/sourcepath/file.txt destionationLocation , you can use the below script to achieve automation.

You just have to give the pull path for source and destination file, without typing the scp command.

Ex1.1 Download example using user enter both source and destination path:

#!/bin/bash
#your server's username and Ipaddress
sshhostname="test@192.168.50.83"

#user enter download file location with fileName
echo -n "enter your source location: "

# user enter download destioantion location(where you wants to save file)
read sourcePath
echo -n "enter your destination location: "
read destinationPath

#download command file from source to destionation(local)
scp $sshhostname:$sourcePath $destinationPath

#upload comamnd
#scp $sourcePath $sshhostname:$destinationPath

If you want to change the download to the current location you can set as destinationPath=$(pwd) or destinationPath="." I recommend use $(pwd) which will use your current location.

Ex2.2 upload file which destination is hot code

But you can also hot code source or destination like the below using upload as an example:

destinationPath=”/home/test/Downloads”
scp $sourcePath $sshhostname:$destinationPath

Below is an example upload file in which the destination is been hot code. Please keep in mind, when UPLOAD source is local side, and destination is server side.

#!/bin/bash
# check fw
echo "=========upload file to server SCP====================="

echo -n "enter ip and host name(ex: username@IPaddress ): "
read sshhostname

#source local side
echo -n "enter your local file name (source): "
read sourcePath

#echo -n "enter your destination(upload location full path)Ex: /home/nrgnb/Downloads/: "
#read destinationPath
#server side as destionation
destinationPath="/home/test/Downloads"

#echo $sourcePath $sshhostname:$destinationPath
scp $sourcePath $sshhostname:$destinationPath

Example 2: if Add source after the script ex: script.sh XXX (xxx is the parameter download file)

From the above Example1 script, you have to enter the source and destination location full path with file name, which somehow some people don’t like it, because long and sometimes hard to remember.

Well in this I am showing you another way, instead, you just add the parameter after the script as your file name. So we have given the full path for our source, we just give the filename.

We just add sourcePath=$1 which$1 will take the parameter as a value. Please look at my script for more detail.

#!/bin/bash
sshhostname="username@192.168.50.83"
#assing your location to a variable
location="/home/test/Downloads/"
#echo -n "enter your source location: "
sourcePath=$1
echo -n "enter your destination location: "
read destinationPath
#download file
#echo $sshhostname:$location$sourcePath $destinationPath
sshpass -p 'sshpassword' scp $sshhostname:$location$sourcePath $destinationPath

#sshpass -p '123456' scp $sshhostname:$sourcePath $destinationPath

How to run: ./scriptname.sh downloadFilename

This code will do the same as example 1, but the difference is when you run the script you just add the filename which will save as a variable. This is quite useful, so you can decide whether to use it or not.

original: filename.txt

script: ./script.sh filename.txt

In this script, I also added a sshpass parameter with -p or -e flag will you don’t have to enter ssh password.

  • -e: encrypt the password
  • -p: password, provide password as an argument

syntax:

sshpass -p <ssh password> scp <ssh username> <sourcePath > <destinationPath>

Let me show you an example below, in my server, I had helloworld.txt, which I want to download to the local side. Let's look at the picture, under the local side use ls the command to check my directory, which does not contain helloworld.txt file.

Let run the script with the filename you want to download. Check the directory against should see it download success.

I hope these 3 automation scripts will help you understand using SCP with automation scripts. It’s pretty useful when running SCP because SCP is sometimes hard to remember the pull path, especially downloading or uploading multiple files.

2. FTP

There’re many different types of FTP services, you can decide which to use. I will be using vsftpd, and show how to setup.

2.1 Setup FTP Server (vsftpd)

  1. install VSFTP package apt-get install vsftpd
  2. check status for vsftp:service vsftpd status

if show running been installed success

2.2 set configuration for account

In this part, I am setting account and uploading the directory.

There are two parts for accounts, one is anonymous you can think of it as a guest account, the other one is a normal account. I will teach you both setting you can choose which one to set.If you want both just follow all the step

anonymous account with no password

normal account with username and password

  • 2.2.1 Anonymous account without password
  1. edit configure as below setting

vi /etc/vsftpd.conf

# Allow anonymous FTP? (Disabled by default).
anonymous_enable=YES
anon_root=/var/ftp/pub
#yes no password anonymous
#No password anonymous
no_anon_password=YES

# Uncomment this to enable any form of FTP write command.
write_enable=YES

# Uncomment this to allow the anonymous FTP user to upload files. This only
anon_upload_enable=YES
anon_mkdir_write_enable=YES

#allow user to delete file
anon_other_write_enable=YES

Note:

This option no_anon_password you can set YES, and No, which have different behavior.

set No: need type account anonymous and password as anonymous

set YES: just type account , don;t need password.

Please refer to step 4 for a detailed picture.

2. create an anonymous directory and give permission

sudo mkdir -p /var/ftp/pub
sudo chown nobody:nogroup /var/ftp/pub
chmod a-w -R /var/ftp/pub #or chmod 755 /var/ftp/pub

3. restart vsftp service sudo systemctl restart vsftpd.service

4. Let's login FTP server

FTP Syntax: FTP <host IP address> or with -A option mean anonymous

You can log in with the basic method or using -A without typing the account

if you set no_anon_password=NO then you can use this command to login

you have to type in the account and password, or use the -A option without typing the password.

Note: -A flag only support in window FTP

5. Upload files setting

We need to create a directory that will store your uploaded files, if you don’t create another directory will occur 553 error if you change permission for login directory will occur 500 error as below:

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

Step1: ftp to server
Step2: Enter username and password
Step3: go into files to upload files
Step4: upload files

sudo mkdir -p /var/ftp/pub/files
chmod a+w -R /var/ftp/pub/files #or chmod 777 /var/ftp/pub/files

6. allow delete file setting, please add below in vsdftp.conf

anon_other_write_enable=YES

  • 2.2.2 login with FTP account with a password
  1. edit configure as below setting

vi /etc/vsftpd.conf

# You may restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#upload to home directory
chroot_local_user=YES

user_sub_token=$USER
local_root=/home/$USER/ftp

2. Restart vsftp

restart vsftp: sudo systemctl restart vsftpd.service

3. create FTP account

Syntax: adduser <ftp username>
sudo adduser ftpuser

it will let you enter password, please refer below:

4. create directory and permission:

SYNTAX: sudo mkdir /home/<username>/ftp

4.1 Create home directory for ftp to login

sudo mkdir /home/ftpuser/ftp

4.2 Assign ownership to this directory
sudo chown nobody:nogroup /home/ftpuser/ftp

4.3 Set permission for ftp directory to login

sudo chmod a+w /home/ftpuser/ftp or chmod 777 /home/ftpuser/ftp

5. Login FTP server using FTP username and upload

Syntax login: FTP <host IP>

Step1: ftp to server
Step2: Enter username and password
Step3:upload files

  • 553 and 550 Could not upload files

update 2023Jun

I mentioned above section 2.2.1 , but would like to mention it again here.

If you ever meet this issue, I had been figuring it out these couple of days and finding out the solution. I find many resources but sem no help, so I make some experiments, and this is the solution.

The reason is FTP have a login directory that only allows you to download file, but if you want to upload file this directory is not allowed. You need to create another directory, for example, upload and change the permission into chomd 777 /upload, then it is able to upload.

This step is the same as above, let me show again:

#copy from above
sudo mkdir -p /var/ftp/pub/upload
sudo chown nobody:nogroup /var/ftp/pub
chmod a-w -R /var/ftp/pub #or chmod 755 /var/ftp/pub
#change the upload firecotry to upload to full acess
chmod a+w -R /var/ftp/pub/upload #or chmod 777 /var/ftp/pub/files

If you only change the login directory to chmod 777 /var/ftp/pub then you will see this error message when upload. 500 OOPS: vsftpd: refusing to run with writable root inside chroot()

recap:

Error MSG: 500 => login directory is set to chmod 777 please change to come 755

Error MSG: 553 => add one more directory to upload file and change permission to chmod 777

2.3 FTP command for upload and download

  • enable hash to show the download bar as below: hash

default is disable

As you can see if you download file , without enable hash will not know the process of downloading process. When enabling the hash it will show like process bar below with #

  • download file command: get filename.txt
  • upload file command : put filename.txt

2.4 Advance FTP setting (option)

You can skip if you’re not interested in setting some advanced settings, but I think I should mention some advanced settings. Indeed there’re many more but I might not cover all of them

2.5 add firewall on port

sudo ufw allow 20/tcp #ftp port
sudo ufw allow 21/tcp #ftp port
sudo ufw allow 40000:50000/tcp #passive ftp
sudo ufw allow 990/tcp #tls
sudo ufw efw enable

check firewall rule status: sudo ufw status

2.6 add userlist manage FTP user

You can use userlist file to manage your FTP account, you can add or delete the username. This is a pretty great way to manage an account, without this is pretty hard to manage.

  • Prerequisite

We need to create an account first, then add a username in this file, if you want to disable the username, you can just remove the username in the file, then the account will be deactivated.

Syntax: adduser <ftp username>
sudo adduser ftpuser

  1. go t vsftp config and edit blow

vi /etc/vsftpd.conf

userlist_enable=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO

Note: the location must be in /etc/vsftpd.userlist else will not work

2. create userlist file to store all account

vi /etc/vsftpd.userlist, add the user in this text file

ftpuser

anonymous

now let log in, it MUST be able to log in

3. remove username from list

Now let disable ftpuser this account, and login will fail. I mark # which is same as remove.

2.7 Deny FTP users to access ssh

We added FTP User account, but we can also not allow it to access SSH connection, just by editing the configuration.

  1. Let login to ftpuser this account by SSH without adding any configure

SSH command: SSH <username>@<HostName or IP>

2. exit to logout

3. Modify sshd_config to disable access from SSH for this account

vi /etc/ssh/sshd_config

add DenyUsers ftpuser in the last line and restart ssh service

sudo service sshd restart

4. let's repeat the first step to login ssh with the same account should be denied

Please refer below picture, when I try to access to this account will occur Permission Denied

let mark # in front of DenyUser , and login again MUST be able to login, please refer below picture

Note: for people not knowing tail -f it just to show the last 10 line if the sshd_config file

2.8 Secure FTP with TLS

As previously we set FTP is not encrypted, you can think as your credentials and files you send are vulnerable or can by easier be hacked. To solve this issue we have to add encrypted using FTP OVER SSL/TLS.

So this is how we can do, please refer this setting.

  1. Creating a new certificated with the openssl tool

Create certificated using openssl tool as

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem

Ask you the information, you don’t have to type in , just press Enter to all question.

2. edit /etc/vsftp.config

Add below setting into /etc/vsftp.config. There is a default SSL inside vsftp.config, but you just have to mark comment or remove. When you install step 1 command, the SSL path is different from vsftp.config, so we have to changed it. Please refer below picture.

#FTP with TLS
#rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
#ssl_enable=NO
ssl_enable=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
allow_anon_ssl=NO
force_local_data_ssl=NO
force_local_logins_ssl=NO
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH

3. restart vsftp server

restart vsftp : sudo systemctl restart vsftpd

check vsftp status: sudo service vsftpd status

4. connect FTP server

  • Use Filiza client:

Please follow below step add ftp account, the most important one is the encryption to TLS

to check your certificate please use below method

  • window CMD prompt

Using Window CMD will login fail need to encryption

To solve this issue please use below method

edit vi /etc/vsftpd.config and add NO to below

force_local_data_ssl=NO

force_local_logins_ssl=NO

restart vsftp : sudo systemctl restart vsftpd

2.9 Upload to a Web Server

1. Install apache webserver

sudo apt-get install apache2 -y

Default location for webserver : ll /var/www/html/index.html

2. Set permission and ownership

set permission /var/www as home directory

sudo usermod -d /var/www ftpuser

Set ownership to ftpwebuser

sudo chown ftpuser:ftpuser /var/www/html

4. Edit vsftpd.config

Comment out the home directory in vsftp.config if you wants to use HTTP directory . If you wants to use the default directory for vsftp need to add back.

user_sub_token=$USER
local_root=/home/$USER/ftp

5. restart ftp server

sudo systemctl restart vsftpd.service

6. login FTP server again

As you can see above the home directory is using /var/www/

If you wants to recover back to original home directory to /home/ftpuser/ftp you just add back below to /etc/vsftpd.conf

user_sub_token=$USER
local_root=/home/$USER/ftp

I have uploaded the full vsftpd.conf, if you’re interested, you can download in my github.

2.10 window (thirty-party tool)

If you don’t want to setup under Linux, instead of using window, you can use many open sources FTP server such as FileZilla server, 3CDaemon, and many other tools. There are many types of FTP servers, you can just google it.

But I usually use FileZilla server or 3CDaemon. I like using 3CDaemon because it also have TFTP and FTP server which is pretty convenient for me. FileZilla server is also a good option, keep in mind FileZilla also have a client version, so please notice it else you will install the wrong tool. Below is an example for FTP in 3CDaemon

FTP clients, you can use the window default command line with FTP command, or FileZilla client is also a good option. It allows us to store hostIP, username, and password.

3. TFTP

TFTP allows you to transfer files without a username and password, which is pretty convenient, which is alike wget. So let me teach you how to set up TFTP server in ubuntu, and also teach you to use the third-party tool under the window.

Setup tftpserver unbuntu

  1. Install package tftpd-hpa for server, tftp-hpa for client

install server: # sudo apt-get install tftp-hpa tftpd-hpa

2. Check the status

$sudo systemctl status tftpd-hpa

3. Configuring TFTP Server

The default configuration file of tftpd-hpa server is /etc/default/tftpd-hpa modify the /etc/default/tftpd-hpa configuration file , below is the default setting:

I only want to change the TFTP_DIRECTORY to /var/tftpboot and add the –create option to the TFTP_OPTIONS.

Note:You can name any tftp_directory name, as long as the directory exists, and please create the folder or the directory is not exist. Next step will teach you

Without the –create option, you won’t be able to create or upload new files to the TFTP server.

-c: Allow new files to be created
-s: Change root directory on startup.
-l: Run the server in standalone (listen) mode, rather than run from inetd.

4. Create/TFTP directory and change the owner and group

Create a TFTP-directory folder: sudo mkdir /var/tftpboot

Change permission: $chmod 777 /var/tftpboot

5. restart tftp server

restart tftp service: sudo systemctl restart tftpd-hpa

check service status:sudo systemctl status tftpd-hpa

check process status(option): ps axnu | grep tftp

6. Test upload or download file

Now let try to test it upload and download file. 192.168.50.83 is my ubuntu server Ip address.

TFTP command Syntax: tftp -i <HostIP> <put|get> filename

tftp -i [IP ADD] [PUT|GET][ FILE NAME]
-g: get file (download)
-r: remote
-p: put file (upload)
-l: local

upload file from window ->Ubuntu under window PC:

tftp -i 192.168.50.83 put filename

Download file from Ubuntu ->window under window PC:

tftp -i 192.168.50.83 get filename

Linux command is different:

syntax: tftp [-g|-p] -r FILENAME SERVERIP

-g: get file
-r: remote
-p: put file

Upload: tftp -p -r test.txt 192.168.1.50

Download:tftp -g -r test.txt 192.168.1.50

Window third-party tool

There are couples of third-party tool, the most tool I use are tftp64 and 3CDaemon

Let me talk basically about these two tools, and these tools are open source and free. I am not going to talk about how to use this tool, if you are interested in it, please let me know thanks.

3CDaemon: support TFTP, FTP, and Syslog server. I use it often for TFTP and FTP transfer files. I use this for TFTP and FTP servers and is one of my best tools for transferring files.

tftp64: support TFTP server, DHCP, Syslog, and DNS. I use it for tftp and some time on setting the DHCP server. I have written a related post on setting up pxe-server which introduces how to use this tool.

There is more tool you can find yourself, but I recommend these two tools.

4. SAMBA

Samba is pretty useful when you can transfer files from Linux to Windows or Windows to Linux. Basely it’s just like sharing a folder so both platforms can use it just like this:\\IPaddress\foldername

  1. check whether samba is been installed or not sudo dpkg -l | grep samba

2 install the samba package

sudo apt-get install samba samba-common

after this continue to step 1 to check the samba package (option)

3. create samba directory and give permission

sudo mkdir shareFolder

sudo chmod 777 shareFolder

4. edit SAMBA configuration

  • guest account with no password

If you want to access without a username or password then add the below to this configuration

Edit smb.conf

[sharefolder]
comment = sharefolder
browseable=yes
path = /sharefolder
guest ok = yes

right now go to the window use the keyboard shortcut window+R and enter \\hostIP it should have a network directory as below:

a restart SMB service: sudo service smbd services

  • with account with password

If you want to have an account username and password please use below setting

I’m using my original username so I am not going to create a new username and password, if you want to create a new username use this command:

create username: sudo useradd <username>

create password for smb: sudo smbpasswd -a test

Edit smb.conf

[account]
comment = test-account
path = /shareFolder
browseable=yes
create mask=0644
directory mask=0755
valid users=test
write list=test

so we use the account as test.

Note: if you use the original sam as the system username, then just type in above. But if you create a new username, then you have to add in the new account name, and the config should change your new account name (valid users=test).

This is pretty useful for remote management settings, highly recommend you should learn this skill.

Window setup samba(window server access window client)

Under Window, we are also able to set up as below which is more easier way.

  1. Create a directory you wants and right-click to share this folder as below

If you want to access without password, then you can set below setting to disable password.

Linux access window samba

If you want to access from Linux to window samba server, there is a package you can use to access cifs-utils samba

  1. install package: sudo apt-get install cifs-utils
  2. create directory to store mount path: sudo mkdir /mnt/testfile/
  3. mount :

syntax:

sudo mount.cifs //windowip/folder/ /linux folder/ -o user=Administrator,password

#with password
mount.cifs \\192.168.1.1/file /mnt/testfile/ -o user=Administrator,password=123456
# without password (guest)
mount.cifs \\192.168.1.1/file /mnt/testfile/ -o user=Administrator,password=''

5. NFS

NFS is almost like samba but setup is much easier, NFS means network file server. I will show you how to set up NFS in Ubuntu, and use window to access the file server.

setup NFS server

1. Install NFS server: sudo apt-get install nfs-kernel-server

2. create a directory to be your NFS server directory ex: /nfs_share , so create it: $mkdir /nfs_share (you can create any name you like)

3. change premission $chmod 777 –R /nfs_share

4. edit exports file vi /etc/exports

option for configure:

rw (Read and Write )

sync (Write changes to disk before applying them)

no_subtree_check (Avoid subtree checking )

5. Export the shared directory: $exportfs -- a

6. restart NFS server: $systemctl restart nfs-kernel-server

7. see mount success or not: $showmount--exports

NFS client

Let access to NFS server from ubuntu or window:

Ubuntu

  1. install NFS client: sudo apt install nfs-common

2. create a directory to mount location:

sudo mkdir -p /mnt/client_shared_folder

3. mount it

sudo mount 192.168.88.86:/mnt/server_shares /mnt/client_shared_folder

window

  1. enable nfs client

2. run cmd and enter below commad

mount 192.168.2.1:/nfs_share x:\

From here you should already most of the tools to transfer files, the most common people who use platforms are Windows VS Linux, so I guarantee that most of the tools I share above can be used by both platforms. I think the majority of people will b using Linux with commands, and Windows will use thirty-party open source tools.

6. CURL

Curl is the default Linux command, which means you don’t need to install FTP TFTP package, instead using the CURL command. This command is default with MAC(Unix) or Linux all support this command, this command is powerful it can use FTP and HTTP with CURL.

Note: We can use -o parameter to rename download file’s name

Download FTP Command

SYNTAX: curl -T filename -u username:password ftp://ipaddress/

curl -T filename ftp://example.com/this/directory/

Upload FTP Command

SYNTAX :curl -u anonymous:anonymous -T [file name] [url]

curl -u anonymous:anonymous -T test.html ftp://ipaddress/

Upload FTP multiple Command

curl -u anonymous:anonymous -T {file1,file2} ftp://ipaddress/

Download HTTP Command -o overwrite exisit file

curl -o filename.tar.gz http://filename.tar.gz

Upload HTTP Command

curl -u anonymous:anonymous -O http://ipaddress/iperfcommand.txt

SMTP uploads

curl -T mail smtp://mail.example.com/ --mail-from user@example.com

7. WGET

Wget is another method you can download and upload HTTP and FTP files

- HTTP Download

#Download file: 
http://XXXX/.zip

#Download file change name:
wget -O filename.zip http://www.domain.com/filename.zip

#Download file at background:
wget -b http://www.domain.com/filename.zip

#Download multiply files:
wget - force-html -i filename.html

#Download limit file:
wget - limit-rate=200k http://www.domain.com/filename.tar.gz

#Download http with password:
wget - http-user=USERNAME - http-password=PASSWORD http://domain.com/filename.html

- FTP Download

#FTP Method: 
wget - ftp-user=USERNAME - ftp-password=PASSWORD ftp://ftp.domain.com/filename.tar.gz

Conclusion

In this post I have mentioned many different ways to help establish a transfer file, some need to install a package, some default commands, and third-party tool.

I hope this post will help you set up how to remote transfer files, which will help you increase efficiency in your daily work; to be more productive.

Since most of the commands are CLI command lines, so we are able to do automation.

I know there are many other great tools that I might not mention here. I only share the tool I use often, and I think it’s pretty handy if you work with Linux commands.

Lastly, if you have any other questions, please free to leave a comment.

--

--

CC(ChenChih)
Chen-Chih’s Portfolio Page

I self study technology, and likes to exchange knowledge with people. I try writing complex tech blog into simple and various ways for people to understand.