Script to mount nas-share using generated credentials (mount EC 13,32)
Heyas
At home i have 1 nas with 3 shares, of which i used to mount 2 of them using a script with hardcoded password and username in it.
EDIT: Turns out, its not the script, but 'how i access' the nas share.. (-o user=XY,password=... VS. -o credentials=...).
Figured about credential files, on a home computer, i tried to match this task into a script.
Idea is to provide all infos at the first time, like:
Code:
[sea@localhost ~]$ mount_nas
mount_nas (0.1)
Usage: mount_nas //IP/SHARE /mount/point [username password [domain]]
Example: mount_nas //192.168.10.4/Public /home/sea/net/pub sea ABCDEFG localdomain
Once configured, simply call:
mount_nas SHARENAME
Where SHARENAME will be the credential filename, and was 'generated' from //IP/SHARENAME...
In practice, it mounts the public one, but wont the private one (error codes: 13 & 32).
The 2 handling scripts are these: umount-nas:
#!/bin/sh
export LC_ALL=C
source ~/.config/user-dirs.dirs
IP=192.168.10.110
USR=MYNAME
PW=THEPASSWORD
DOM=THEDOMAIN
# The creation and usage of the credentials work fine...
#mount_nas //$IP/Public $XDG_PUBLICSHARE_DIR $USR $PW $DOM
#mount_nas //$IP/priv $XDG_CLOUD_DIR $USR $PW $DOM
#exit
# Thus, use the benefit of the script
echo;echo; mount_nas Public
echo;echo; mount_nas priv
IP="";USR="";PW="";DOM=""
During the 'tests' both shares have the same password, but for some reason, one gets mounted the other not.
Code:
umount: /home/sea/priv/nas: nicht eingehängt
Loaded settings: Public (//192.168.10.110/Public)
0 Mounted: /home/sea/net/pub (//192.168.10.110/Public)
Loaded settings: priv (//192.168.10.110/priv)
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
32 Failed: /home/sea/priv/nas (//192.168.10.110/priv)
//192.168.10.110/Public on /home/sea/net/pub type cifs (rw,relatime,vers=1.0,cache=strict,username="MYUSERNAME",domain="MYDOMAIN",uid=0,noforceuid,gid=0,noforcegid,addr=192.168.10.110,unix,posixpaths,serverino,acl,rsize=1048576,wsize=65536,actimeo=1)
[sea@localhost ~]$ clear ; umnt-nas ; mnt-nas ; echo ; mount|grep 192 ; echo
The actual script is: mount_nas
PHP Code:
#!/bin/sh export LC_ALL=C # # Author: sea (Simon Arjuna Erat) # Contact: erat.simon@gmail.com # Created: 2014.17.11 # Description: If all required variables (2-3) are provided, it creates # a credentials file which it'll be using at 2nd usage, # if you just pass the sharename of an already used NAS entry. # NOTE: There must be no identical names on diffrent NAS! # # Variables # ME=$(basename $0) source ~/.config/user-dirs.dirs script_version=0.1 hlp_txt="\n$ME ($script_version)\nUsage:\t\t$ME //IP/SHARE /mount/point [username password [domain]] \rExample:\t$ME //$(for STR in [a-z];do ip addr|awk '{print $2}'|grep ^$STR -A2|grep -iv ::|grep -iv 127|grep [0-9].[0-9].[0-9]|sed s,"/"," ",g|awk '{print $1}';done)/Public $XDG_PUBLICSHARE_DIR$USER ABCDEFG $(hostname|sed s,'\.',' ',g|awk '{print $2}')\n\nOnce configured, simply call:\n\t\t$ME SHARENAME\n\t\tWhere SHARENAME will be the credential filename, and was the full //IP/SHARENAME...\n" NAS_CFG_DIR="$HOME/.config/script-tools/nas" [ ! -d "$NAS_CFG_DIR" ] && mkdir -p "$NAS_CFG_DIR NAS="$1" ; MP="$2" ; CREDS=""
[sea@localhost nas]$ mnt-nas
0 Loaded settings: Public (//192.168.10.110/Public)
Credential formatted incorrectly: (null)
domain="ocean"
Credential formatted incorrectly: "//192.168.10.110/Public"
Credential formatted incorrectly: "/home/sea/net/pub"
mount.cifs kernel mount options: ip=192.168.10.110,unc=\\192.168.10.110\Public,iocharset=utf8,file_mode=0777,dir_mode=0777,sec=ntlm,user="simon",,domain="ocean",pass=********
0 Mounted: /home/sea/net/pub (//192.168.10.110/Public)
0 Loaded settings: priv (//192.168.10.110/priv)
domain="ocean"
Credential formatted incorrectly: //192.168.10.110/priv
Credential formatted incorrectly: /home/sea/priv/nas
mount.cifs kernel mount options: ip=192.168.10.110,unc=\\192.168.10.110\priv,iocharset=utf8,file_mode=0777,dir_mode=0777,sec=ntlm,user="simon",,domain="ocean",pass=********
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
32 Failed: /home/sea/priv/nas (//192.168.10.110/priv)
I really dont get it
Both shares share the same uid/pw combination, they just differ by the Sharename.
Ok, the credential file is formatted incorrectly.. both times, but only one doesnt work.
If both would not work, i'd sure say its because i stored the full-adress (//IP/sharename) as well as the mountpoint (/home/sea/priv/nas).
But since 1 of 2 work, me back at the beginning... :clueless:
My HP-UX server currently mounts a directory on a Windows 2012 server. The Windows server allows anonymous connections for RW and this configuration has worked well for years. Now, due to tightening security requirements I can't use anonymous. I also can't setup Identity Mapping on the Windows... (5 Replies)
I need a help of good people with effective bash script to mount nfs shared,
By the way I did the searches, since i haven't found that someone wrote a script like this in the past, I'm sure it will serve more people.
The scenario as follow:
An NFS Client with Daily CRON , running bash script... (4 Replies)
The UPS connected to the Disk Array portion of my Windows 2003 NAS burned up over the weekend. Reconnected it to a new UPS and re-booted the NAS box. Since then I have not been able to get my HPUX 10.2 box to mount the shared drives on the NAS. At boot, the NFS client & server subsystems do a... (0 Replies)
HI
I would like to ask about my virtualbox 4.0.4 in my lucyd lynx box
My shared forlder isn't auto mount in my linux guest OS. And everytime i manually mount using command sudo mount -t vboxsf <shared_folder_name> <Guest_location> it throw an error msg "/sbin/mount.vboxsf: mounting failed... (1 Reply)
all,,i need help,,i try to mount a windows 2000 share folder to my system,,i already userd smb mount,mount -F and bunch of stuff and none is working,,can anyone give me a script to this??
PS : when i use mount -F i got this message :
nfs mount: insufficient privileges ,,,
is it must be root ? (6 Replies)
Hello,
I have a few Ubuntu 9.10 laptops I'm trying to learn NFS sharing with. I am just experimenting on this right now, so no harsh words about the security of what I'm playing with, please ;)
Below are the configs
/etc/exports on host
/home/woodnt/Homeschool... (2 Replies)
Hi, How can i mount an NFS share on a solaris machine a filesystem ?
I have enabled nfs on a windows server and the shares has given read/write access to it to all the users. I would like to mount it on around 10 different solaris boxes with different versions of solaris.
Thanks in advance. (2 Replies)
Hi,
I try to mount an external USB HD on a solaris 10 without any success.
Machine hardware: i86pc
OS version: 5.10
Processor type: i386
Hardware: i86pc
The HD is a zfs, but I installed this with a Ubuntu 8.10.
iostat -En displays this:
--> so the system... (0 Replies)
Hello,
I am having difficulty compressing the files using compress or GZIP utility on NAS share NFS mounted on my linux server. Any one have idea on how to do this ? I get the followign error but the trying to compress the files
STRP2> compress STR_OUTBOUND_CDM_LOG_LOB.PRT2008_26.txt... (1 Reply)
I've got a Sco 5.0.6 box and an Ubuntu box on my network. i want to backup certain directories onto a share on the Ubuntu box. how do i mount a linux share onto the Sco box? (1 Reply)