Can I save a username/password pair for an ftp server in some local configuration file, so that lftp will find them automatically when connecting to that server?
Background: I have script which will be used by multiple users, with different username/password pairs, to sync some generated content from a repository to an ftp server. It would be nice not to have to enter our usernames/passwords by hand each time. Since ftp passwords are sent in cleartext, we are all using low-value passwords for this, so storing the passwords in cleartext in a local config file is acceptable.
You can use ~/.netrc file or lftp bookmarks.
Add something like this to ~/.netrc:
machine your.server.example.com login your_login password your_password
Then lftp will pick the password when opening ftp://your_login#your.server.example.com, and it will use your_login automatically when opening "your.server.example.com" without the URL syntax.
When using bookmarks, do "set bmk:save-passwords true" (default is false), then save the current session to bookmarks under a name, then "open bookmark_name" will use the login/password pair. The bookmarks file is plain text, so you can even add the URL with login/password by any text editor. To use a common bookmarks for all users set LFTP_HOME environment variable to a common directory.
Just some more details about lftp bookmarks:
First add line set bmk:save-passwords yes to the main lftp config file /etc/lftp.conf.
Now every user can add his own bookmark:
lftp -c "bookmark add SiteName ftp://user:password#sitename.com/path"
When using lftp in a script just use: lftp -c "open SiteName && lcd MyLocalDir && mput ./"*
Related
I have a team set up on bitbucket with multiple users, and I'm using the keyring extension for mercurial. I need to set up a subrepo, and in the .hgsub file I need to provide the url for the subrepo.
If I use https://bitbucket.org/team/subrepo then the user needs to authenticate each time they try to pull.
If I use https://userX.bitbucket.org/team/subrepo then each user will need to authenticate with userX's password.
If I use https://team.bitbucket.org/team/subrepo then each user will need the team's password.
Is there a way I can set it up so that the authentication can be saved using the keyring extension, but still have separate credentials for each user, without using ssh?
Yes, you can enter your authentication information into your config file. The documentation for this is here.
In the auth section of each user's config file you can enter the following details:
[auth]
bb.schemes = http https
bb.prefix = bitbucket.org/team
bb.username = userX
The bb part is just a tag to group the settings together - you can use what you like and you can have more than one set if you have more than one Mercurial server that you use.
The example settings say that all repositories that start http://bitbucket.org/team or https://bitbucket.org/team should use the username of userX. The keyring extension will take care of the password after that.
Has anybody else had an issue with the new Intellij HG4IDEA not working in Windows? Whenever I try to pull from a remote repository it just hangs, never asking for my ssh username/password.
My initial thought was that I should set my username/password in mercurial.ini somehow.
It just sits like this indefinably, if I try to cancel it it will not stop.
You need to configure it to work with your keys without password or
use ssh client that is able to ask password in a dialog window, like
TortoisePlink.exe.
When using console SSH client, there is no way for IDEA to see if it's
requesting passwords and provide them (it's just not supported, so ssh
client must either work without asking anything in the console or ask
a password via dialog).
See also
http://youtrack.jetbrains.net/issue/IDEA-62230 and http://youtrack.jetbrains.net/issue/IDEA-56004.
In order to get Intellij 10 to work with hg4idea I just changed my mercurial.ini file in my user directory of windows.
# Generated by TortoiseHg setting dialog
[extensions]
hgext.convert=
[ui]
username = myusername
[trusted]
users = *
groups = *
[ui]
ssh="C:\Program Files\TortoiseHg\bin\TortoisePlink.exe"
The key was to set ssh= to a client that supports prompting for passwords.
I use mercurial in my project, and every time I push new changesets to the server by ssh, it ask me for a password.
Then how to config the mercurial to push with out asking password?
I works on Ubuntu 9.10
On Linux and Mac, use ssh-agent.
Ensure you have an ssh keypair (see man ssh-keygen for details)
Copy your public key (from ~/.ssh/id_dsa.pub) to the remote machine, giving it a unique name (such as myhost_key.pub)
Log in to the remote machine normally and append the public key you just copied to the ~/.ssh/authorized_keys file
Run ssh-add on your local workstation to add your key to the keychain
You can now use any remote hg commands in this session without requiring authentication.
Assuming you're using Windows, have a read of my Mercurial/SSH guide. Down the bottom of the post you'll find info on how to use PuTTy to do this for you.
Edit: -- Here's the part of the post that I'm talking about (bear in mind you'll need to have pageant running with your key already loaded for this to work):
Client: Setting up Mercurial
If you haven't already, make sure you install Mercurial on the client machine using the default settings. Make sure you tell the installer to add the Mercurial path to the system PATH.
The last step of configuration for the client is to tell Mercurial to use the PuTTy tools when using SSH. Mercurial can be configured by a user-specific configuration file called .hgrc. On Windows it can also be called Mercurial.ini. The file is located in your home folder. If you don't know what your home folder is, simply open a command prompt and type echo %USERPROFILE% - this will tell you the path.
If you haven't set up your configuration yet, then chances are the configuration file doesn't exist. So you'll have to create it. Create a file call either .hgrc or Mercurial.ini in your home folder manually, and open it in a text editor. Here is what part of mine looks like:
[ui]
username = OJ Reeves
editor = vim
ssh = plink -ssh -i "C:/path/to/key/id_rsa.ppk" -C -agent
The last line is the key and this is what you need to make sure it set properly. We are telling Mercurial to use the plink program. This also comes with PuTTy and is a command-line version of what the PuTTY program itself does behind the scenes. We also add a few parameters:
-ssh : Indicates that we're using the SSH protocol.
-i "file.ppk" : Specifies the location of the private key file we want to use to log in to the remote server. Change this to point to your local putty-compatible ppk private key. Make sure you user forward-slashes for the path separators as well!
-C : This switch enables compression.
-agent : This tells plink to talk to the pageant utility to get the passphrase for the key instead of asking you for it interactively.
The client is now ready to rock!
Install PuTTY.
If you're on Windows, open projectdir/.hg/hgrc in your favorite text editor. Edit it to look like this:
[paths]
default = ssh://hg#bitbucket.org/name/project
[ui]
username = Your Name <your#email.com>
ssh = "C:\Program Files (x86)\PuTTY\plink.exe" -ssh -i "C:\path\to\your\private_key.ppk" -C -agent
If it's taking forever to push, the server might be trying to ask you a question (but it's not displayed).
Run this:
"C:\Program Files (x86)\PuTTY\plink.exe" -T hg#bitbucket.org -i "C:\Program Files (x86)\PuTTY\plink.exe" -ssh -i "C:\path\to\your\private_key.ppk"
Answer any questions, and then try pushing again.
If you're using Bitbucket, open your private key with puttygen, copy your public key out of the top textbox, and add it to your user account: https://bitbucket.org/account/user/USERNAME/ssh-keys/
Is there a way to configure TortoiseHg to store my password?
I have a project hosted on Google Code that I access using TortoiseHg. Whenever I want to push changes to Google Code TortoiseHg prompts me for a username and password. Google Code requires me to use an auto-generated password, and it gets quite repetitive to look it up every time.
Both existing answers suggest storing your username and password unencrypted in plain-text, which is a bit of a no-no.
You should use the Keyring extension instead, as it has been specifically designed for securely saving authentication passwords. It already comes bundled with TortoiseHg, so all you have to do is activate it by writing the following in your mercurial.ini file:
[extensions]
mercurial_keyring=
You will also have to associate your username with the push url by editing your repository-specific .hg\hgrc file like in the example below:
[paths]
default = https://<your_username>#bitbucket.org/tortoisehg/thg
For more details on associating your username with the url, see the Repository Configuration (SMTP) section of the Keyring extension page.
Three steps, watch screenshot.
Note: This stores your password in plaintext.
Security warning
Although this answer is accepted as of 2017-09-15, it is not a recommended solution. You should never store your passwords in plain text. Use the mercurial_keyring extension instead. See another answer here.
You can change your push URL to https://username:password#hostname.com/repo.
This is explained in Google Code's and Mercurial's FAQs.
EDIT: Mercurial FAQ explains another way to do it:
With Mercurial 1.3 you can also add an auth section to your hgrc file:
[auth]
example.prefix = https://hg.example.net/
example.username = foo
example.password = bar
If you want to configure it via TortoiseHg, Repository Setting dialog is available.
After opening the dialog, please switch to 'Sync' tab.
You can add a path with HTTPS auth information.
http://tortoisehg.bitbucket.io/manual/2.9/settings.html#module-web.settings
Simply modify the hgrc file in the .hg directory of your local repository so it looks like this:
[paths]
default = https://name:password#yourproj.googlecode.com/hg/
where name is your Google Code login without the gmail/googlemail bit e.g. 'fredb' (not fredb#gmail.com), password is the Google-generated password, and yourproj is the name of your GC project. So something like:
default = https://fred:xyz123#fredproj.googlecode.com/hg/
This works for me using SSH. I know the password it's in text plain, but this is not a problem in this project.
You have to change myUser and MyOPas for your credentials and the path to: TortoisePlink.exe.
Edit the mercurial.ini
[reviewboard]
password = myPass
[ui]
username = myUser
ssh = "C:\Program Files\TortoiseHg\lib\TortoisePlink.exe" -l myUser -pw myPass
If you want to store the password in mercurial.ini and it doesn't work anymore after you upgrade to TortoiseHg 4.9 or higher a possible solution is to add the port to the prefix:
[auth]
tax.prefix = http://server:8080
tax.username = cerveser
tax.password = mypassword
Here's the scenario. I have a simple browse button. Right now, it opens up the folder hierarchy on my local computer. (PC).
However, I want to pick a file from a remote unix server which I have access to. Is there a way to display the file hierarchy of the remote unix server WITHOUT having to mount the drive?
Are there other options other than using a java applet?
Thanks,
Michael
If you don't really want an applet you can do it server-side in PHP by using this something like this to let the user select a folder:
<?php
$connection = ssh2_connect('host', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, 'ls -a --file-type');
?>
Just parse the $stream variable to identify the folders (the ones ending with /) and present them in a table.
I guess this solves your problem. If you want the user to upload a file just put a simple file upload field, Once the user have selected a folder and uploaded a file in a temporal location in the server just move it with SSH too:
<?php
$connection = ssh2_connect('host', 22);
ssh2_auth_password($connection, 'username', 'password');
ssh2_scp_send($connection, '/temporal/filename', '/remote/filename');
?>
For getting this working you need to have enabled SSH2 libraries for PHP in your server.
Don't know how it is in Unix, but in Windows, you can either map a drive letter to remote path, or simply type the remote path in the browse dialog (\\server\share\filename)
Instead of using the regular input type file, invoke a Java applet. You can use VFS from apache to access your UNIX machines. VFS API supports many file access protocols.
http://commons.apache.org/vfs/filesystems.html
A friend of mine recommended Samba:
http://us3.samba.org/samba/
It apparently lets you link a unix server as a windows file/print server, which should show up in a file browser. :)
I don't know why; I've had much difficulty with installing anything on the solaris machine. So i've decided to go a slightly different route -- I found out that the machine is already mounted properly, so I can simply switch user accounts to access what I need -- without SSH.