Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
11-16-2016, 07:33 AM
|
#1
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Rep:
|
Linux to Windows sharing WITHOUT manual password entry
I have been trying for weeks now to be able to transfer files from Linux to Windows with minimal success. I already have a Powershell script created that grabs files from a Linux directory but I want to have a bash script to do this instead. In my Powershell script it uses a host key right in the script. I want to insert the host key in a bash script too. So since it works in Powershell, I figured when I created a bash script it would not ask for a password because of the previous use of this authentication, but it still asks for a password. I want the process to be fully automated.
|
|
|
11-16-2016, 07:41 AM
|
#2
|
LQ Guru
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342
|
passwords, it is coming and going. It wouldn't matter if you psychically log in you have to enter a password regardless of which system you're logging into.
Same with scripts. The thing you could do is insert the password within your script to be entered each time, or set it up so no password is actually needed to preform this task.
set it up for auto authentication with some type of hash code.
think of how Bluetooth works it has a trusted certificate, so when that same phone is connected it is automatically allowed access.
each device holds this record. the pc and the phone both know each other and was given a trust account. No password is needed.
Last edited by BW-userx; 11-16-2016 at 07:45 AM.
|
|
1 members found this post helpful.
|
11-16-2016, 08:17 AM
|
#3
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
Can you please show me how to do this, with and without a password. Smbclient looks promising. I looked at everything from smbclient, scp, sftp, etc and have got nowhere
Last edited by trickydba; 11-16-2016 at 08:18 AM.
|
|
|
11-16-2016, 08:35 AM
|
#4
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,185
|
Quote:
Originally Posted by trickydba
Can you please show me how to do this, with and without a password. Smbclient looks promising. I looked at everything from smbclient, scp, sftp, etc and have got nowhere
|
Putting "how to map a windows share in linux" into Google pulls up many examples. This one:
Code:
/usr/bin/mount -t cifs -o dir_mode=0777,file_mode=0777,username=someuser,password=somepassword //10.11.12.13/Shared/Windows/Folder /local/linux/folder
...uses the built-in CIFS file system and the existing mount command to mount a Windows share to a folder in Linux. Replace variables with what matches your Windows server/user/password/share and the desired folder for Linux. Don't want to put the password in the script? Then just delete the ",password=somepassword" from the above command. It'll then prompt you for a password.
|
|
1 members found this post helpful.
|
11-16-2016, 08:42 AM
|
#5
|
LQ Guru
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342
|
I have the concept not the actual how to. I'd have to get two OS, one Windows, and One Linux and figure it out myself.
Where is your script you are using now. is their not an area where it gets to the log in, then add the password to be entered within that script.
here in this post it shows smbclient -N to suppress a password.
http://www.computerhope.com/unix/smbclien.htm
maybe wait to see if someone else that has more experience with this to answer. Seeing how you're looking for everything.
|
|
1 members found this post helpful.
|
11-16-2016, 08:54 AM
|
#6
|
Moderator
Registered: Aug 2002
Posts: 26,191
|
The easiest would be to mount a windows share using fstab with a credentials file as shown above. You can then transfer files using the cp command.
There are other methods like using expect or heredoc but for services other then windows file sharing you will need to install a server (sftp, ftp etc) on the Windows PC.
Last edited by michaelk; 11-16-2016 at 08:57 AM.
|
|
1 members found this post helpful.
|
11-16-2016, 09:38 AM
|
#7
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
Well I just tried this using Samba. It gives no errors but upon checking the directory on the Win side, the file has not been copied
smbclient //blah.blah.com\\ /foldertowriteto usernameofWinShare%pswdOfWinShare -c "put filename.txt"
What am I doing wrong???
|
|
|
11-16-2016, 09:46 AM
|
#8
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
@TB0ne..I tried your suggestion.the response..... only root can do that 8.((((
|
|
|
11-16-2016, 09:54 AM
|
#9
|
Moderator
Registered: Aug 2002
Posts: 26,191
|
The correct syntax is:
smbclient //windows_PC/share_name -c "put source_file_name destination_file_name"
Did you create a share for the desired directory? I did have to review the man pages for smbclient and it also can use a credentials file using the -A option.
The credentials file format is:
username = mywinuser
password = mywinpass
You can specify the password and username on the command line.
Last edited by michaelk; 11-16-2016 at 09:58 AM.
|
|
1 members found this post helpful.
|
11-16-2016, 10:04 AM
|
#10
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
@michaelk..ok I did that and it's asking for oracle's password. I tried EVERY password I have, none work 8.(
|
|
|
11-16-2016, 10:04 AM
|
#11
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
It should not be THIS hard ugh!
|
|
|
11-16-2016, 10:08 AM
|
#12
|
Moderator
Registered: Aug 2002
Posts: 26,191
|
smbclient defaults to the clients username i.e. who you are logged in as. It depends how you created the share on the windows box (allows users and password). You need to use the windows username via the -U option.
smbclient //windows_PC/share_name password -U username -c "put source_file_name"
Last edited by michaelk; 11-16-2016 at 10:11 AM.
|
|
1 members found this post helpful.
|
11-16-2016, 10:17 AM
|
#13
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
@michaelk..........I tried what you suggested, put the password in and get Error NT_STATUS_UNSUCCESSFUL. I even did -U username%password, that didn't even work 8.((
|
|
|
11-16-2016, 10:18 AM
|
#14
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep:
|
Funny thing is, the name and password works in WinSCP! But I doing this in Linux and want it to be non-interactive
|
|
|
11-16-2016, 10:26 AM
|
#15
|
Moderator
Registered: Aug 2002
Posts: 26,191
|
What version of windows are you running? The linux username/password is not necessarily the same as the windows username/password. With WinSCP you are using your linux credentials, with smbclient you are using the windows credentials.
Assuming your not running a domain, LDAP or AD authentication etc.
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 06:54 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|