0

In the Ubuntu tutorial for how to share a folder via Samba, the instructions direct to install samba (Successful), add an entry to the configuration file (completed) then the instruction where I am having an issue: "On Ubuntu: Open up the default file manager and click Connect to Server then enter:" For reference, here is the link to this instruction: https://tutorials.ubuntu.com/tutorial/install-and-configure-samba#3

The trouble is that I am doing this on a remote AWS instance. Since I am, I don't have the GUI based file manager to work with, only a terminal via SSH. I know I could set this up on a VNC server / client pair to access this, which I will do later, but I don't have time now, as this will be time consuming and involve some troubleshooting. Is there a way to connect this folder to the server to share from the terminal instead of using the file manager?

Davidt
  • 1

3 Answers3

2

Connecting to Samba from the terminal command line

The file browser users a resource such as gio (or gvfs-mount) to mount the device. The address you are seeing as a suggestion to put in can be put into this the gio commandline:

For Ubuntu 16.04 and earlier:

$ gfvs-mount "smb://[yourserver]/[yourshare]"

For Ubuntu 18.04 and later:

$ gio mount "smb://[yourserver]/[yourshare]"

You can access the share at:

/run/user/[your user ID]/gvfs

Connecting to the Samba share on computer boot

You can make it permanent by added this to the /etc/fstab file:

//servername/servershare /mysharedfolder cifs nofail,auto,uid=[username],gid=users,file_mode=0660,dir_mode=0775,iocharset=iso8859-15,credentials=/etc/smbpasswd 0 0

The /etc/smbpasswd file is a text file with this format:

username=[username]
password=[passsword]

The [name] is to be replaced with credential information. Don't include the brackets.

L. D. James
  • 25,444
0

You can use SSHFS - Secure Shell File System

Local

Install SSHFS

$ sudo apt install sshfs

Create Local Folder for Remote Mount. This can be any folder you like, but for example I use:

$ mkdir -p ~/sshfs/[remote-host name]

Mount Remote Folder at Local Folder

$ sshfs -o idmap=user [remote user]@[remote ip address]:[path to remote folder] [path to local folder]

This will give you a local folder that maps to a remote folder, that you can browse via terminal or Nautilus (file manager).

Auto Mount suggestions here

But I believe there is a more elegant solution via /etc/fstab configuration.

Unmount Remote Folder from Local Folder

$ fusermount -u [path to local folder]
Broadsworde
  • 4,532
0

connect with smbclient

  1. install smbclient:

    sudo apt-get install smbclient

  2. list available shares on host:

    smbclient -L <host>

  3. connect:

    smbclient \\\\<host>\<sambashare> -U <username> # you'll be asked to enter the password

source:https://www.tldp.org/HOWTO/SMB-HOWTO-8.html