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
  • The picture of the text in your question doesn't help very much. If you want to share text, it would be better to copy and paste the text rather than placing a picture of the text in your post. A link to the page would also make it easier to receive the information. Actual text is so much easier to read than pictures of text. – L. D. James May 29 '18 at 15:32
  • Thank you for your feedback. I will make some revisions. – Davidt May 29 '18 at 15:36
  • Opening a network share through the file manager is equivalent to performing a mount statement with mount type = cifs. Install cifs-utils if you haven't already, then see this question. – Jos May 29 '18 at 15:39
  • Thank you for putting me a step closer to resolving this issue. I tried this: $sudo mount type=cifs /home/ubuntu/development ... This gave me the error: mount: special device type=cifs does not exist. I will research this, but if you know off the top of your head, I appreciate your help more than I could express. – Davidt May 29 '18 at 15:49
  • Use -t cifs, not type=cifs. – Jos May 29 '18 at 16:11
  • By the way, which version of Ubuntu are you running? For 16.04 LTS the cli command is gvfs-mount for samba. For version 18.04 LTS the cli command is gio mount for samba. The /etc/fstab automount on boot is the same for both versions. – L. D. James May 29 '18 at 16:32

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,036
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,132
  • 4
  • 28
  • 45
  • I need it to be permanent. Another possible complication is this instance requires a key pair, not a username and password combination. – Davidt May 29 '18 at 15:54
  • if you already have a key pair setup for SSH, it will already work for SSHFS... for permanency I will need to get some input from a more experienced user. – Broadsworde May 29 '18 at 15:57
  • mkdir ~/sshfs/home/ubuntu/development gives me: "mkdir: cannot create directory ‘/home/ubuntu/sshfs/home/ubuntu/development’: No such file or directory" ... if I do cd /home/ubuntu/development it takes me to the directory with no problem. If I try to create a new directory: mkdir ~/sshfs/home/ubuntu/development2, I get the same error. It doesn't matter if it is with a new directory I am creating or an existing directory. – Davidt May 29 '18 at 16:22
  • sorry I forgot the -p (create parent) switch... updating my answer – Broadsworde May 29 '18 at 16:51
  • Now the third line "sshfs -o idmap=user [remote user]@[remote ip address]:[path to remote folder] [path to local folder]" errors out with "remote host has disconnected" , even though the instance is online and I am connected to it on another terminal via SSH. – Davidt May 29 '18 at 20:49
  • I found another AskUbuntu question on that subject: https://askubuntu.com/questions/777116/sshfs-giving-remote-host-has-disconnected#777524 – Broadsworde May 30 '18 at 05:05
  • I checked the config file that this question addressed. this is correct. I restarted the ssh server as they said to do. this still doesn't work. I am using an FTP client for now, but I hope I can get this better solution working soon. – Davidt May 30 '18 at 13:28
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