LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 11-16-2016, 07:33 AM   #1
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Rep: Reputation: Disabled
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.
 
Old 11-16-2016, 07:41 AM   #2
BW-userx
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

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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.
Old 11-16-2016, 08:17 AM   #3
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-16-2016, 08:35 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,185

Rep: Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064Reputation: 8064
Quote:
Originally Posted by trickydba View Post
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.
Old 11-16-2016, 08:42 AM   #5
BW-userx
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

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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.
Old 11-16-2016, 08:54 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,191

Rep: Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087
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.
Old 11-16-2016, 09:38 AM   #7
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
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???
 
Old 11-16-2016, 09:46 AM   #8
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
@TB0ne..I tried your suggestion.the response..... only root can do that 8.((((
 
Old 11-16-2016, 09:54 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,191

Rep: Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087
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.
Old 11-16-2016, 10:04 AM   #10
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
@michaelk..ok I did that and it's asking for oracle's password. I tried EVERY password I have, none work 8.(
 
Old 11-16-2016, 10:04 AM   #11
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
It should not be THIS hard ugh!
 
Old 11-16-2016, 10:08 AM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,191

Rep: Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087
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.
Old 11-16-2016, 10:17 AM   #13
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
@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.((
 
Old 11-16-2016, 10:18 AM   #14
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
Funny thing is, the name and password works in WinSCP! But I doing this in Linux and want it to be non-interactive
 
Old 11-16-2016, 10:26 AM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,191

Rep: Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087
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.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Create manual entry in kernel source vviivveekkk Linux - Kernel 2 03-04-2014 03:46 PM
No manual entry for smidump akagrawal3 Linux - Newbie 1 02-08-2013 09:10 AM
Manual entry for gzcat abhinav4 Linux - Newbie 6 08-17-2011 06:29 PM
how to get manual entry for capinfo abirami Linux - Networking 1 10-14-2004 11:14 AM
Samba: Removing password on Linux to Windows sharing nairnie Linux - Networking 2 11-26-2003 06:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration