First of all, you should really use keyring like gnome-keyring to store password. Storing plain password in a text file is never a good idea. Keyring extension is available for mercurial. However, if you don't want to hassle with the mumbo jumbo and really don't mind the plain password, you can use the following method to prevent mercurial asking for username/password while syncing to server. (while push and pull) In your .hgrc file add entry like below: [auth] server1.prefix = bitbucket.org/user/repo/ server1.username = username server1.password = password server1.schemes = http https server1.prefix = * server1.username = username server1.password = password server1.schemes = http https Now the explanation part: [auth] defines the section for authentication. You have to group prefix, username, password and schemes with one string. It can be any string but whatever follows that string is part of that group. prefix is the url, you can use wild card he