0

I have a rather large file(s), which I'd like to share between two Linux boxes on the same network. I'm somewhat familiar with scp, but how do I configure it on the host? That is, how does the host allow the client to connect? Or, is it that when you login with scp, or ssh, that since you login with username and password, just use a username and password which are on the host machine?

That is, just login to the host with an existing user/password?

I'd be interested in a GUI, along the lines of Windows File Sharing, if that's possible.

Thufir
  • 4,641

5 Answers5

3

The Quick & Dirty way would be to open up a port for an incoming connection on the sending side and then connect the receiver to the sender on that port and then send files over the connection. This will be the fastest method to transmit data within the LAN as there will be no encryption, transmission and other overheads usually associated with the SSH. Although keep in mind that this process will not use any authentication and encryption mechanism. This is helpful when you are transferring file inside the LAN between trusted hosts.

On the sending side:

nc -l <port> < /file/to/be/sent

For example:

nc -l 5000 < /home/user/test

On the receiving side:

nc <sender_ip> <port> > /where/to/be/saved

For example:

nc 192.168.0.5 5000 > /home/myself/new_file
heemayl
  • 94,145
  • instead of nc you can use /dev/tcp// feature - for example: cat /etc/passwd >/dev/tcp/1.2.3.4/1234 will send /etc/passwd into 1.2.3.4 host and port 1234 using tcp

    But - both methods are insecure - files aren't encrypted between hosts :-)

    – undefine Feb 01 '15 at 22:26
2

SCP works using the same credentials as SSH.

If you can SSH from host A to host B using this command:

ssh username@hostb

then the command to SCP a file from host A to host B would be:

scp /path/to/file username@hostb:/path/to/destination

If you are interested in a GUI you could try using the default Files (nautilus) -> Go -> Enter Location ... and typing in:

sftp://root@hostb/path/to/destination

I know its not SCP but its still fairly easy. Alternatively you could take a look at Filezilla.

2

I would consider using NitroShare. NitroShare is a simple file sharing GUI program. It can be installed using

sudo add-apt-repository ppa:george-edison55/nitroshare
sudo apt-get update
sudo apt-get install nitroshare

You can launch it from your Desktop's menu (Dash, in the case of Unity), and the program will open in the system tray. It will need to be opened on both the computer sending the file and the one receiving it.

Fabby
  • 35,075
TSJNachos117
  • 1,532
1

if you want "easy way" copy files between hosts - i recommend you use mc (midnight commander). You have there option "shell link" - for easy connect to remote host using ssh.

For automating use of it - use ssh-keys - on client please do:

ssh-keygen -t dsa

and press enter few times, and then copy key to server:

ssh-copy-id -i .ssh/id_dsa.pub user@server

then - you can connect using ssh/scp protocols from client to server without using password.

undefine
  • 478
1

One of the easiest (both to setup and use) solutions is NFS. NFS is a client-server model, so one machine has to be a server while the other is a client

Configuration settings

folder-to-share -> Path to the folder you want to share

server-ip-address -> IP of the machine hosting the shared folder

client-ip-address -> IP address of the machine accessing the shared folder (use network address such as 192.168.1.0 to allow any machine to access)

Server

sudo apt-get install nfs-kernel-server
echo '/<folder-to-share>/ <client-ip-address>/255.255.255.0(rw,no_root_squash,no_subtree_check,sync)' | sudo tee --append /etc/exports

Client

sudo apt-get install nfs-common
echo '<server-ip-address>:<folder-to-share> /media/share        nfs rw,hard,intr 0 0' | sudo tee --append /etc/fstab
sudo mount /media/share

You can now browse the share as you would any other folder.

Hakkar
  • 121
  • There's really no point in running echo as a root user. As long as tee is run as root, tee will still be able to modify the output file. – TSJNachos117 May 13 '15 at 05:10