I have two questions here. I am able to mount a windows network path in my Ubuntu machine by doing following:
sudo mount -t cifs -o username=user \\\\my_windows\\test /net/loc
All the files and folders present in Windows machine is now available in Ubuntu machine with path '/net/loc'.
Here are my doubts:
I can see all files of windows in linux path. Is it possible to create files/folders in Linux path(the mount path where windows path is mounted) and it will be reflected in Windows machine? I am not able to write in Linux machine where windows network location is mounted. It throws me error "Can't open file for writing".
I am trying to write a shell script (a ksh file) which will mount the windows network path. I wrote the below mount command in my file but this command prompts for password. Is there any way, I can write the command in shell script that it will not ask me for password and I can pass it as either as a parameter or some other mechanism?
mount -t cifs -o username=user \\my_windows\test /net/loc
Thank you
Password can be passed as below
sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=,gid= //server-address/folder /mount/path/on/ubuntu
And with root access I am able to write in Linux path.
More information is here https://unix.stackexchange.com/questions/68079/mount-cifs-network-drive-write-permissions-and-chown
Related
Trying to copy files from remote windows pc into my local linux using shell script.
Can someone please tell me how this can be done?
You can use smbclient to connect to the windows shared directory:
smbclient -L <ip address> -U <windows user>
Alternatively, you can mount a shared directory using smb mount:
mkdir /mnt/local_share
sudo mount -t cifs //<ip address/<shared directory> /mnt/local_share
I am trying to set my GOPATH to a shared network folder. When I enter
export GOPATH=smb://path/to/shared/folder
I get:
go: GOPATH entry is relative; must be absolute path: "smb".
Run 'go help gopath' for usage.
I've also tried to prefix the path w/ "/" but then it tries to make a folder in root.
thx!
there is only one solution for this:
Map ( mount) a Samba server file path as a Local Disk Drive ( local path),
then set GOPATH to this local path:
Mounting SMB share on local folder by using smbmount command (smbmount is deprecated):
smbmount //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname
Example :
smbmount //192.168.0.1/share1 /mnt –o username=steev,workgroup=test
Mounting SMB share by using mount command
mount –t smbfs ipadd:/sharename /mountpoint –o username=userid,workgroup=workgroupname
Or
mount –t smbfs //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname
Example :
mount –t smbfs 192.168.0.1:/share1 /mnt –o username=surendra,workgroup=test
ref:
http://www.linuxnix.com/8-ways-to-mount-smbfs-samba-file-system-in-linux/
https://askubuntu.com/questions/232998/how-do-i-install-smbmount
http://www.howtogeek.com/116309/use-ubuntus-public-folder-to-easily-share-files-between-computers/
and for Windows: https://serverfault.com/questions/6079/how-can-i-mount-an-ftp-to-a-drive-letter-in-windows
You need to mount the Samba share to a folder on your machine:
$ mkdir /mnt/samba
$ smbmount smb://path/to/share /mnt/samba
Of course you may need to use switches on the smbmount command to provide username, password, workgroup, etc., depending on the configuration of the Samba share you're trying to access. Once you've mounted the share you can then do
$ export GOPATH=/mnt/samba
And as far as Go is concerned the files in the Samba share will be located on your local machine.
I'm trying to get a Linux VM using Virtual Box, Virtual Box Guest Additions, and Vagrant running and to mount a folder on my Windows 7 machine. I've tried the suggestions in this question, but still get the same error.
I'm running the following versions:
Virtual Box: 4.3.18 r96516
Virtual Box Guest Additions: 4.3.18
Vagrant: 1.6.5
Vagrant Plug-ins:
vagrant-login: 1.0.1
vagrant-share: 1.1.2
vagrant-vbguest: 0.10.0
When I run vagrant reload I get the following error:
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,
nolock,vers=3,udp,noatime core /tbm
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,nolock,vers=3,udp,noa
time core /tbm
The error output from the last command was:
stdin: is not a tty
unknown mount option `noatime'
valid options:
rw mount read write (default)
ro mount read only
uid =<arg> default file owner user id
gid =<arg> default file owner group id
ttl =<arg> time to live for dentry
iocharset =<arg> i/o charset (default utf8)
convertcp =<arg> convert share name from given charset to utf8
dmode =<arg> mode of all directories
fmode =<arg> mode of all regular files
umask =<arg> umask of directories and regular files
dmask =<arg> umask of directories
fmask =<arg> umask of regular files
I've tried un-installing, installing, updating the vagrant-vbguest plugin:
vagrant plugin install vagrant-vbguest
I've tried running the following command after running vagrant ssh, but still get the same error message:
sudo ln -s /opt/VBoxGuestAdditions-4.3.18/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
I'm not super familiar with mount options, but I tried executing your command in a similar VM I'm running and got the same error regarding the noatime option.
I read through the documentation (man 8 mount) which states somewhere after line 300 or so, in the FILESYSTEM INDEPENDENT MOUNT OPTIONS that: Some of these options are only useful when they appear in the /etc/fstab file.
I suspect this is your problem. I edited my /ect/fstab file to change one of my mounts to /dev/mapper/precise64-root / ext4 noatime,errors=remount-ro 0 1 this option and then ran the following:
sudo mount -oremount /
vagrant#precise64:~$ mount
/dev/mapper/precise64-root on / type ext4 (rw,noatime,errors=remount-ro)
...
I edited the file again to remove the option and:
vagrant#precise64:~$ sudo mount -oremount /
vagrant#precise64:~$ mount
/dev/mapper/precise64-root on / type ext4 (rw,errors=remount-ro)
...
I don't know if you're providing these mount commands or if they come from a plugin, but it seems like (at least in your environment), the option works fine, but can't be specified on the command line.
I want to run a shell script using SSH which takes resource from other machine while the script is in some other machine, all on the same network. I don't want to copy the resource to the local machine.
Note: The shell script takes .txt file as input
If you have script.sh on server1 and file.txt on server2, you can connect through ssh to server1, and then do:
[user#server1]$ ssh user#server2 "cd mydir && cat file.txt" | ./script.sh
Try this:
ssh USER_NAME#HOST_ADDRESS "BASH_SCRIPT_FILE_PATH"
You will need to provide password whenever required.
If your script is in Machine A, you can't run that on Machine B without copying it over. First, copy the script over to Machine B using scp
[user#machineA]$ scp /path/to/script user#machineB:/home/user/path
Then, just run the script
[user#machineA]$ ssh user#machineB "/home/user/path/script"
This will work if you have given executable permission to the script.
OR
Try this one..
<hostA_shell_prompt>$ ssh user#hostB "ls -la"
That will prompt you for password, unless you have copied your hostA user's public key to the authorized_keys file on the home of user .ssh's directory. That will allow for passwordless authentication (if accepted as an auth method on the ssh server's configuration)
I not fully understand your question. Other answers gave "How to run remote script?"
But i think question is Remote script has to take remote file, even I not sure about this
Login Remote PC using ssh.
Install sshfs if not installed .
Then mount other remote machine directory which has the file you want to use in script to local directory. This can be done using sshfs
Then run the script with file from locally mounted directory
Then unmount the directory when you finished.
Somewhat large procedure.
Mounting remote directory with sshfs
man sshfs
I'm worknig on a remote codebase via vagrant development environment and I use sshfs for mounting the remote point on my localhost as below:
sshfs hostname:vagrant_remotemountpoint mountpoint
To copy a file to the vagrant vagrant_remotemountpoint first I open the mountpoint via nautilus and then paste the file into it. Now I like to do this process using a shell command.
Anybody has done such an effort? Thanks.
Have you tried cp somefile mountpoint on shell? With sshfs, mountpoint should appear like a normal directory on your system.