ownCloudcmd with netrc on Windows doesn't work

Expected behaviour

By running ownCloudcmd with option "-n" crendtials should get from "_netrc file" on Windows, instead of prompting for the credentials. (see https://doc.owncloud.org/desktop/latest/advancedusage.html)

Actual behaviour

I created a "_netrc" file in %USERPROFILE% with follwing content. Reduce ACLs to FullControl by current user only. Create new environment varialble %HOME% pointing to the user profile and test it.

Content of "_netrc":
machine example.domain.com
login LoginName
password Password

Tested on Windows 10 and Windows 7. With and without reducing the ACLs. I got everytime a prompt for username and password. The sync works, if I enter the credentials or using "-u" & "-p" option. If I use "--non-interactive -n" I get an authentication failed error.

Is there anything more to do on a Windows Client. For example anything to install like "Git for Windows"?

Steps to reproduce

  1. Created a "_netrc" file in %USERPROFILE% with follwing content.
    Content of "_netrc":
    machine example.domain.com
    login LoginName
    password Password
  2. Create new environment varialble %HOME% pointing to the user profile.
  3. Running command: "ownCloudcmd -n localPath ownCloud.url"

Server configuration

Operating system: Ubuntu

Web server: Apache

Database: unknown

PHP version: unkown

ownCloud version: 10.0.2

Storage backend (external storage): Auto-Tier (SSD+SAS) Storage Virtualization

Client configuration

Client version: 2.3.2.6928

Operating system: Windows 7 and Windows 10

OS language: German

Qt version used by client package (Linux only, see also Settings dialog): -

Client package (From ownCloud or distro) (Linux only): -

Installation path of client: C:\Program Files (x86)\ownCloud

Logs

Please use Gist (https://gist.github.com/) or a similar code paster for longer
logs.

Template for output < 10 lines

  1. Client logfile:
    !!! OCC::JsonApiJob created for "https://example.domain.com" + "ocs/v1.php/cloud/capabilities" ""
    void OCC::AbstractNetworkJob::slotFinished() QNetworkReply::NetworkError(AuthenticationRequiredError) "Host requires authenticat
    ion" QVariant(int, 401)
    Network error: "ocs/v1.php/cloud/capabilities" "Host requires authentication" QVariant(int, 401)
    Server capabilities QVariant(Invalid)
    Set proxy configuration to use system configuration
    [9] csync_exclude_load Adding entry: *~
    [9] csync_exclude_load Adding entry: ~$*
    [9] csync_exclude_load Adding entry: .~lock.*
    [9] csync_exclude_load Adding entry: ~*.tmp
    [9] csync_exclude_load Adding entry: ].~
    *9] csync_exclude_load Adding entry: ]Icon
    [9] csync_exclude_load Adding entry: ].DS_Store
    [9] csync_exclude_load Adding entry: ].ds_store
    [9] csync_exclude_load Adding entry: ._*
    [9] csync_exclude_load Adding entry: ]Thumbs.db
    [9] csync_exclude_load Adding entry: desktop.ini
    [9] csync_exclude_load Adding entry: System Volume Information
    [9] csync_exclude_load Adding entry: .*.sw?
    [9] csync_exclude_load Adding entry: ..sw?
    [9] csync_exclude_load Adding entry: ].TemporaryItems
    [9] csync_exclude_load Adding entry: ].Trashes
    [9] csync_exclude_load Adding entry: ].DocumentRevisions-V100
    [9] csync_exclude_load Adding entry: ].Trash-*
    [9] csync_exclude_load Adding entry: .fseventd
    [9] csync_exclude_load Adding entry: .apdisk
    [9] csync_exclude_load Adding entry: .htaccess
    [9] csync_exclude_load Adding entry: .directory
    [9] csync_exclude_load Adding entry: *.part
    [9] csync_exclude_load Adding entry: *.filepart
    [9] csync_exclude_load Adding entry: *.crdownload
    [9] csync_exclude_load Adding entry: *.kate-swp
    [9] csync_exclude_load Adding entry: .gnucash.tmp-
    [9] csync_exclude_load Adding entry: .synkron.*
    [9] csync_exclude_load Adding entry: .sync.ffs_db
    [9] csync_exclude_load Adding entry: .symform
    [9] csync_exclude_load Adding entry: .symform-store
    [9] csync_exclude_load Adding entry: .fuse_hidden*
    [9] csync_exclude_load Adding entry: *.unison
    [9] csync_exclude_load Adding entry: .nfs*
    [9] csync_exclude_load Adding entry: My Saved Places.
    There are 174374588416 bytes available at "C:/Users/UserName/ownCloud/Test1/" and at least 50000000 are required
    ===== new sync (no sync journal exists)
    "===== Using Qt 5.6.2 SSL library OpenSSL 1.0.2h 3 May 2016 on Windows 7"
    sqlite3 version "3.16.1"
    Detected filesystem "NTFS" for "C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db"
    sqlite3 journal_mode= "wal"
    bool OCC::SyncJournalDb::checkConnect() possibleUpgradeFromMirall_1_5 detected!
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "checkConnect" and starting new transaction
    Columns in the current journal: ("phash", "pathlen", "path", "inode", "uid", "gid", "mode", "modtime", "type", "md5")
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add fileid col" an
    d starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure (remotePerm)" and s
    tarting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add filesize col"
    and starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add inode index" a
    nd starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add path index" an
    d starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add ignoredChildre
    nRemote col" and starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add contentChecksu
    m col" and starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add contentChecksu
    mTypeId col" and starting new transaction
    Columns in the current journal: ("path", "lastTryEtag", "lastTryModtime", "retrycount", "errorstring")
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add lastTryTime, i
    gnoreDuration cols" and starting new transaction
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add lastTryTime, i
    gnoreDuration cols" and starting new transaction
    Forcing remote re-discovery by deleting folder Etags
    Cleared 0 folder ETags
    void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "checkConnect End"
    void OCC::SyncEngine::startSync() ====NOT Using Selective Sync

Discovery start #################################################### >>

=====Server "" "rootEtagChangesNotOnlySubFolderEtags=0"
[6] csync_statedb_load sqlite3 version "3.16.1"
[6] csync_statedb_load Success
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synca4107aad09c8.db [inode=388460 size=81920]
[9] csyncdetect_update .synca4107aad09c8.db excluded (1)
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db [inode=392785 size=4096]
[9] csyncdetect_update .synce45d37c13c63.db excluded (1)
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db-shm [inode=392858 size=32768]
[9] csyncdetect_update .synce45d37c13c63.db-shm excluded (1)
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db-wal [inode=392834 size=127752]
[9] csyncdetect_update .synce45d37c13c63.db-wal excluded (1)
[9] csync_ftw <= Closing walk for C:/Users/UserName/ownCloud/Test1 with read_from_db 0
[8] csync_update Update detection for local replica took 0.03 seconds walking 0 files.
OCC::DiscoveryJob(0x214f840) Calling into main thread...
!!! OCC::LsColJob created for "https://example.domain.com" + "" "OCC::DiscoverySingleDirectoryJob"
Stop request: Authentication failed for "https://example.domain.com/remote.php/webdav/"
void OCC::AbstractNetworkJob::slotFinished() QNetworkReply::NetworkError(OperationCanceledError) "Operation canceled" QVariant(I
nvalid)
void OCC::DiscoverySingleDirectoryJob::lsJobFinishedWithErrorSlot(QNetworkReply*) "Operation canceled" 0 QNetworkReply::NetworkE
rror(OperationCanceledError)
void OCC::DiscoveryMainThread::singleDirectoryJobFinishedWithErrorSlot(int, const QString&) 5 "Operation canceled"
OCC::DiscoveryJob(0x214f840) ...Returned from main thread
5 when opening msg= "Operation canceled"
[4] csync_ftw opendir failed for - errno 5
[6] csync_statedb_close sqlite3_close=0
#### ERROR during csync_update : "An error occurred while opening a folder Operation canceled"
void OCC::SyncJournalDb::close() "C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db"
No database Transaction to commit
CSync run took 160
void OCC::SyncEngine::abort() QObject(0x0)
void OCC::SyncJournalDb::close() "C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db"
No database Transaction to commit!!! OCC::JsonApiJob created for "https://example.domain.com" + "ocs/v1.php/cloud/capabilities" ""
void OCC::AbstractNetworkJob::slotFinished() QNetworkReply::NetworkError(AuthenticationRequiredError) "Host requires authenticat
ion" QVariant(int, 401)
Network error: "ocs/v1.php/cloud/capabilities" "Host requires authentication" QVariant(int, 401)
Server capabilities QVariant(Invalid)
Set proxy configuration to use system configuration
[9] csync_exclude_load Adding entry: *~
[9] csync_exclude_load Adding entry: ~$*
[9] csync_exclude_load Adding entry: .~lock.*
[9] csync_exclude_load Adding entry: ~*.tmp
[9] csync_exclude_load Adding entry: ].~
*9] csync_exclude_load Adding entry: ]Icon
[9] csync_exclude_load Adding entry: ].DS_Store
[9] csync_exclude_load Adding entry: ].ds_store
[9] csync_exclude_load Adding entry: ._*
[9] csync_exclude_load Adding entry: ]Thumbs.db
[9] csync_exclude_load Adding entry: desktop.ini
[9] csync_exclude_load Adding entry: System Volume Information
[9] csync_exclude_load Adding entry: .*.sw?
[9] csync_exclude_load Adding entry: ..sw?
[9] csync_exclude_load Adding entry: ].TemporaryItems
[9] csync_exclude_load Adding entry: ].Trashes
[9] csync_exclude_load Adding entry: ].DocumentRevisions-V100
[9] csync_exclude_load Adding entry: ].Trash-*
[9] csync_exclude_load Adding entry: .fseventd
[9] csync_exclude_load Adding entry: .apdisk
[9] csync_exclude_load Adding entry: .htaccess
[9] csync_exclude_load Adding entry: .directory
[9] csync_exclude_load Adding entry: *.part
[9] csync_exclude_load Adding entry: *.filepart
[9] csync_exclude_load Adding entry: *.crdownload
[9] csync_exclude_load Adding entry: *.kate-swp
[9] csync_exclude_load Adding entry: .gnucash.tmp-
[9] csync_exclude_load Adding entry: .synkron.*
[9] csync_exclude_load Adding entry: .sync.ffs_db
[9] csync_exclude_load Adding entry: .symform
[9] csync_exclude_load Adding entry: .symform-store
[9] csync_exclude_load Adding entry: .fuse_hidden*
[9] csync_exclude_load Adding entry: *.unison
[9] csync_exclude_load Adding entry: .nfs*
[9] csync_exclude_load Adding entry: My Saved Places.
There are 174374588416 bytes available at "C:/Users/UserName/ownCloud/Test1/" and at least 50000000 are required
===== new sync (no sync journal exists)
"===== Using Qt 5.6.2 SSL library OpenSSL 1.0.2h 3 May 2016 on Windows 7"
sqlite3 version "3.16.1"
Detected filesystem "NTFS" for "C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db"
sqlite3 journal_mode= "wal"
bool OCC::SyncJournalDb::checkConnect() possibleUpgradeFromMirall_1_5 detected!
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "checkConnect" and starting new transaction
Columns in the current journal: ("phash", "pathlen", "path", "inode", "uid", "gid", "mode", "modtime", "type", "md5")
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add fileid col" an
d starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure (remotePerm)" and s
tarting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add filesize col"
and starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add inode index" a
nd starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add path index" an
d starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add ignoredChildre
nRemote col" and starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add contentChecksu
m col" and starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add contentChecksu
mTypeId col" and starting new transaction
Columns in the current journal: ("path", "lastTryEtag", "lastTryModtime", "retrycount", "errorstring")
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add lastTryTime, i
gnoreDuration cols" and starting new transaction
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "update database structure: add lastTryTime, i
gnoreDuration cols" and starting new transaction
Forcing remote re-discovery by deleting folder Etags
Cleared 0 folder ETags
void OCC::SyncJournalDb::commitInternal(const QString&, bool) Transaction commit "checkConnect End"
void OCC::SyncEngine::startSync() ====NOT Using Selective Sync

Discovery start #################################################### >>

=====Server "" "rootEtagChangesNotOnlySubFolderEtags=0"
[6] csync_statedb_load sqlite3 version "3.16.1"
[6] csync_statedb_load Success
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synca4107aad09c8.db [inode=388460 size=81920]
[9] csyncdetect_update .synca4107aad09c8.db excluded (1)
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db [inode=392785 size=4096]
[9] csyncdetect_update .synce45d37c13c63.db excluded (1)
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db-shm [inode=392858 size=32768]
[9] csyncdetect_update .synce45d37c13c63.db-shm excluded (1)
[9] csync_walker file: C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db-wal [inode=392834 size=127752]
[9] csyncdetect_update .synce45d37c13c63.db-wal excluded (1)
[9] csync_ftw <= Closing walk for C:/Users/UserName/ownCloud/Test1 with read_from_db 0
[8] csync_update Update detection for local replica took 0.03 seconds walking 0 files.
OCC::DiscoveryJob(0x214f840) Calling into main thread...
!!! OCC::LsColJob created for "https://example.domain.com" + "" "OCC::DiscoverySingleDirectoryJob"
Stop request: Authentication failed for "https://example.domain.com/remote.php/webdav/"
void OCC::AbstractNetworkJob::slotFinished() QNetworkReply::NetworkError(OperationCanceledError) "Operation canceled" QVariant(I
nvalid)
void OCC::DiscoverySingleDirectoryJob::lsJobFinishedWithErrorSlot(QNetworkReply*) "Operation canceled" 0 QNetworkReply::NetworkE
rror(OperationCanceledError)
void OCC::DiscoveryMainThread::singleDirectoryJobFinishedWithErrorSlot(int, const QString&) 5 "Operation canceled"
OCC::DiscoveryJob(0x214f840) ...Returned from main thread
5 when opening msg= "Operation canceled"
[4] csync_ftw opendir failed for - errno 5
[6] csync_statedb_close sqlite3_close=0
#### ERROR during csync_update : "An error occurred while opening a folder Operation canceled"
void OCC::SyncJournalDb::close() "C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db"
No database Transaction to commit
CSync run took 160
void OCC::SyncEngine::abort() QObject(0x0)
void OCC::SyncJournalDb::close() "C:/Users/UserName/ownCloud/Test1/.synce45d37c13c63.db"
No database Transaction to commit

  1. Web server error log: -

  2. Server logfile: ownCloud log (data/owncloud.log): -

Did you try to rename the file from _netrc to .netrc ?

Hi alfredb,

there are severals posts I found in google.com that on Windows it shoul be "_netrc". But yes, I also tried ".netrc." (that last point is necessary, otherwise Windows didn't safe it) -> same thing, still asking for the credentials.

I'm afraid, no. You should get rid off that final point. Try with renaming.

Hi alfredb,

I'm soory, my answer was not clear. If you need a file in Windows without a file extention but a point within the file name you need to create it with an additional point at the end of the filename. Otherwise everthing after the point is the file extention in Windows. In case of ".netrc" would that mean a file without a name. That is not possible.

But the last point just disappear after creating. If you want to call the file, you use ".netrc":

If I google "Windows" with ".netrc" all posts mention to use "_netrc" in Windows. For example:

That why I tried "_netrc". But anyway, both didn't work.

Unfortunately I have to confirm the reported behavior. This made me somewhat curious, so I did some investigations on Win7. Finally I found a solution that works for me:

  1. As I expected, the file is named .netrc - without an decoration!
  2. The file .netrc is located at %HOME%.
  3. The file .netrc contains Linux line endings. This cannot be done with notepad, IFAIK.

After that, I was able to perform a sync without entering my credentials.

I hope this works for you as well.

BTW, regarding the file naming topic: I have many of those "extension-only" files on my machine:

Verzeichnis von C:\Users\me

03.08.2017  11:34    <DIR>          .
03.08.2017  11:34    <DIR>          ..
15.08.2016  10:04               167 .astylerc
06.01.2017  11:27    <DIR>          .atom
03.08.2017  14:02             8'038 .bash_history
12.11.2012  12:43                77 .cvsignore
03.08.2017  11:34               224 .gitconfig
06.05.2016  14:24               161 .gitignore
14.11.2014  17:12                84 .lesshst
29.11.2016  17:45                48 .minttyrc
12.04.2013  10:31                25 .profile
07.11.2014  12:31    <DIR>          .ssh
27.07.2017  12:17            16'581 .viminfo
1 Like

Hi alfredb,

very dump of me, your point 3 was my problem. I created the file with Microsofts Notepad. I converted the EOL Convertion from Windows (CR LF) to Linux (LF) with notepad++ and test it again. Now the authentication works.

Thank you!