Ubuntu – Sharing files in LAN through Samba or SSH

file-sharingsambassh

I am able to share files between two Ubuntu machine and Windows machine but I have these problems which I can't solve.

1. When I share files between two Ubuntu machines via LAN Computer1 to Computer2. Do I need Samba on both machines? If no(relative to upper Question) then in case of transferring p2to
2. When I access another Ubuntu Machine from Ubuntu, without defining file and directory permissions on Computer1 I see all files under / on Computer2. Is there any way to stop that visibility? How to set permissions on the folder or directory I want other users to be able to see? How to set a customized list of shared folders or files?
3. Which user and password i use while accessing other Ubuntu machine samba user or system admin user ? is it work on both. can i use it without password ?
4. How i share file without using GUI samba or using terminal .
5. Why Computer2 is not getting shown on my network connection in Computer1 ?(without using connect to server option)
why my linux system is not shwoing in this?

6. Finding other system without knowing name or IP over LAN?

Help me through this

First of all: if you want to share files, there are several different protocols of interest: Samba (SMB), NFS, FTP, SSH/sFTP/SCP. Samba is the easiest if a Windows computer is involved, but you can use it also between two Ubuntu (and even Mac OS) machines. SSH is a nice thing for Ubuntu, because it's a very powerful tool - e.g. running rsync over SSH is a command method to keep two directories synchronised. But I'd choose SMB because you mention Windows and probably setting up one protocol/server is enough for the beginning.

Only three important hints for further research about other protocols:

• Think about encryption - is it necessary that the protocol is encrypted or do you want to trust your LAN? (FTP is not encrypted, SSH/sFTP/SCP is)
• Do need to transfer huge files? (SCP is really slow compared to SMB in Gigabit networks! Google benchmarks if you are interested.)
• Is it necessary to keep the file permissions of the files transferred?

1. When I share files between two Ubuntu machines via LAN, do I need Samba on both machines?

No, not the Samba server. There will be always a server and a client. You can access the shared folders on the server from the client - not the other way around. In other words: the copying progress bar will be always on the client, never on the server. But with two Ubuntu machines, both of them can be client and server at the same time, if you want. The client is shipped with Ubuntu per default, the server is installed automatically when you share a folder for the first time with Nautilus.

2. Without Defining permission on computer 1 I can see all files under / on computer 2. Is their any way to stop that visibility?

That's not true for SMB/Samba. There are certain shared folders and only these are visible to the clients. Check the folder /var/lib/samba/usershares/ and the file /etc/samba/smb.conf, if the path / is shared. Probably you are connecting with SSH and not with SMB. Then you are right, usually everything is visible and you have to set the file and directory permissions correctly. You can find more details about this here: Simple & easy way to jail users

3. Which user and password do I have to use while accessing other Ubuntu machine through Samba?

Usually it's simple: just use any user and password of the other machine. Only in very special cases the user's normal password differs from his Samba password. You can change the Samba password separately with the command smbpasswd, but you should really have good reasons to use two different passwords.

You can allow shares without password. There are many things to say about this, but probably this Nautilus screenshot helps for the beginning:

4. How to share files without GUI using the terminal?

The most common use case is SSH/SCP then probably. Just type the following in the client's terminal to copy /path/to/file1 on the client to /path/to/file2 on the server:

scp /path/to/file1 server:/path/to/file2


server can be an IP address or a domain name. Or another method already mentioned in other answers with rsync:

rsync /path/to/file1 server:/path/to/file2


With Samba you probably would use smbmount (which is not shipped with Samba per default) in order to mount a network share on the client. Then you can use it normally. There are many ways to mount a Samba share. If you are using Gnome, gvfs-mount might be the easiest method:

gvfs-mount smb://server/nameOfsharedFolder
cd ~/.gvfs/*


5. Why is the server not showing up in Nautilus / Network on the client?

As far as I know, the first time it doesn't show up there. After connecting to it once, you'll find it there. The first time, you will have to click "Windows Network", then "Workgroup" and then you'll see your server - hopefully. At least this was the result of my tests.

6. How to find the other system without knowing name or IP of the other system in LAN?

You can use nmap in the terminal, for example:

nmap 192.168.0.*


if 192.168.0.0 is your LAN. This will print you all network clients in your LAN (which can be discovered). Sometimes this might help, if other machines don't show up under Network.