Closed nbarnwell closed 8 months ago
Cygwin is supported already. Is there a reason that something beyond cygwin support is wanted?
Well, not wanting to have to install Cygwin for one thing. I typically have a powershell window open so I'd use that.
well, a quick google shows that you can use cygwin in a powershell window: http://geekswithblogs.net/alexmoore/archive/2010/03/18/using-cygwin-with-powershell.aspx
so that leaves the one who actually not wanting to install cygwin.
I think it's reasonable enough to not want to install Cygwin just to run a specific command-line tool, and even more reasonable to not want to risk compatibility issues running Cygwin in the PowerShell prompt?
To be clear, using Cygwin is a sensible hack/workaround in the meantime while the current version is being made feature complete and bugs fixed etc. It's just that at some point a native Windows app (packaged up on Chocolatey) would be excellent.
I'll merge a windows build recipe if someone can make a decent one and send a pull request. I'm just not the person to do it, speaking as someone who almost never uses windows and then only grudgingly, and thus probably cannot do a good job of it.
I would agree with the OP on this. I personally love linux, but there are millions of people using Windows and windows only environments. A lot of them rely on powershell scripting instead of installing cygwin, especially if they have to interact and/or manage other Window's machines on the environment.
Sure. We don't have any binaries releases at this time though. A make recipe would be welcome.
I'll see if I can take a look maybe this weekend, but no promises.
Any updates on this? I would also like to use the Lastpass CLI from Windows without having a dependency on cygwin.
For someone interested in giving it a try, the following page may be useful: https://www.gaia-gis.it/gaia-sins/mingw_how_to.html
We need openssl, curl, and libxml.
I was able to build and run lastpass-cli on Windows 10 using the Windows Subsystem for Linux (aka Bash on Ubuntu on Windows) instead of Cygwin.
This requires Windows 10 version 1607 or newer. Instructions for enabling bash can be found here: https://msdn.microsoft.com/en-us/commandline/wsl/install_guide#enable-the-windows-subsystem-for-linux-feature-gui
First I installed Git and cloned the repo
apt-get install git
git clone https://github.com/lastpass/lastpass-cli.git
cd lastpass-cli
Then I installed the dependencies listed for Ubuntu in the readme
apt-get install openssl libcurl4-openssl-dev libxml2 libssl-dev libxml2-dev pinentry-curses xclip
Then I ran the build command but it didn't work because I didn't have any build tools installed (doh!)
apt-get install cmake build-essential
Then I ran the build command again and it worked. :)
cmake . && make
Note that commands with --clip
do not work because there is no integration with the clipboard.
Edit Scroll down for additional instructions to enable clipboard integration. https://github.com/lastpass/lastpass-cli/issues/83#issuecomment-522845572
Thanks, @StevenLiekens! Please send a pull request if you'd like to add this build information to README.md. I don't know if there is a kind of xclip / pbcopy work-alike on windows but we can add support for it if such a thing exists.
Bob, I remember reading that clipboard integration is not yet implemented. If I understand correctly then it means that xclip and friends simply can't work in this version of the subsystem.
Additionally, while having this run in the WSL is nice, ideally it will also eventually be compiled and run natively.
We store passwords in LastPass Enterprise, but being able to access them from PowerShell scripts (run interactively) via a LastPass CLI would be useful. Again agree that installing Cygwin or running within the Windows Subsystem for Linux is only suitable as a workaround.
Hi! That's quite a headache, but I finally did make this work "transparently" on Windows. Here are the steps:
lpass.ps1
:
$lpassArgs = $args -join " "
Invoke-Expression "&`"C:\cygwin64\bin\bash.exe`" -l -c `"/usr/local/bin/lpass $lpassArgs`""
$PROFILE
):
Set-Alias -Name lpass -Value c:\scripts\lpass.ps1
./Do-SomethingSecure.ps1 -Password $(lastpass show -p entry-name)
This is a lot to take in for a developer who wants lastpass to make things "simpler for them". Maybe a better alternative to building this would be a completely different project, built in C# that would allow using PowerShell objects (e.g. Get-LastPass -Name myentry | % { echo $_.Id }
)
Anyway, I hope this will help other people wanting to use lpass in PowerShell :)
@StevenLiekens I just tried it on Windows 10 1703 and a newly installed Windows Subsystem for Linux running Ubuntu 16.04. However, it failed with the below error message. Any idea?
_~/lastpass-cli$ cmake . && make -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Call Stack (most recent call first): /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:52 (find_package_handle_standard_args) CMakeLists.txt:8 (findpackage)
@janegilring sounds like PkgConfig is not installed. Perhaps that was not required by the make script when I wrote my comment. I didn't run into that issue.
Install PkgConfig and try again.
apt-get install pkg-config
@StevenLiekens Thanks, that was it. The build completed and now I have lpass in the ~/lastpass-cli folder. However,when trying to run it I get a message stating that lpass is not installed, and that I can install it using sudo apt install lastpass-cli. Would that also be an alternative when using Bash on Windows? Update: I forgot ./...it runs when calling it using ./lpass. What's the difference between the version we download and build, and the one we install using apt install lastpass-cli?
Bump this. We need an official PS module for Lastpass.
Bump :)
I would love a native port for Windows, since then I would be able to use lastpass as the secrets-source when provisioning machines via configuration management.
@petemounce has a very good point. Windows CLI support could open Lastpass up to a whole new enterprise use case.
Guys, total agreement here, but I am not a windows developer, so someone needs to show up with a build recipe :)
Anyone?
@bcopeland I'm sorry you're taking the brunt of the feedback when you're not in a position to take direct action on it, but are you telling us that there are no Windows developers in the Lastpass organization? This is something they should be willing to put a bit of money into. Imagine how much this could drive adoption of Lastpass Enterprise. There's money to be made here.
@christianrondeau Re this comment: that's certainly one way to do it. I just do make && make install
in cygwin and have the cygwin /bin
folder on my global user PATH. This lets me use any cygwin binaries (including lpass
) from powershell/cmd etc.
I personally really dislike cygwin, mainly because it is very difficult to have multiple installations. But it is also pretty bloated in my experience. I just hacked together a build for lpass in MSYS2. I was actually aiming to build against MINGW libs rather than MSYS but this worked out OK as a demo.
The only patch required to get it working was the following:
diff --git a/http.c b/http.c
index 0af8b17..b5953ec 100644
--- a/http.c
+++ b/http.c
@@ -39,6 +39,7 @@
#include "version.h"
#include "pins.h"
#include "cipher.h"
+#include "config.h"
#include <stdarg.h>
#include <stdint.h>
#include <errno.h>
@@ -277,6 +278,7 @@ char *http_post_lastpass_v_noexit(const char *server, const char *page, const st
memset(&result, 0, sizeof(result));
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_USERAGENT, LASTPASS_CLI_USERAGENT);
+ curl_easy_setopt(curl, CURLOPT_CAINFO, config_path("ca-bundle.crt"));
if (lpass_log_level() >= LOG_VERBOSE) {
logstream = lpass_log_open();
A more complete port would fix the code that sets the config dir, but I lazily worked around that by setting the env var LPASS_HOME
in the supplied batch file.
Disclaimer: this build has dlls and trusted CA certs bundled in for convenience. These won't get security updates, and I make no guarantees that this build is secure! But the basic functionality does appear to work.
lpass-msys-proof-of-concept.zip
Just extract it somewhere and add the folder to your PATH. There's probably a dependency on some MSVC runtime, but I couldn't tell you which one.
Build process - in MSYS2 terminal:
pacman -Sy
pacman -Syuu (Repeat until it says no more packages can be updated. You might need to restart MSYS2.)
pacman -S mingw-w64-x86_64-gcc make tar openssl cmake git libcurl libxml2 pinentry libcurl-devel libxml2-devel openssl-devel
pacman -Syuu (Update the packages)
git clone https://github.com/lastpass/lastpass-cli.git
<apply code patch>
cd lastpass-cli && make
<manually bundle dlls and batch file>
edit: the bundled certs were copied from msys64\usr\ssl\certs in my installation
edit 2: saving this as a note for later if I find some time to put together a proper PR https://stackoverflow.com/a/40046425/7706514
Nice work!
@bcopeland Is this going in/out to LastPass-Cli? People did a lot of good work here. Is you guys have no time to support that, let's close the issue here. Overall I'd expect that (a) with something like https://chocolatey.org it should be easy to do a working package (b) a lot of Windows users can use apt-get
now in Windows with steps ^^^. Maybe someone with Windows could just make a PR?
This works in WSL using the steps here here from @StevenLiekens. To get --clip
to work you'll need to install and run Xming as well as add this to your ~/.bashrc
:
export DISPLAY=:0
I got bogged down chasing who got a working build on MSYS2, and what branch they built on, and tried running the Zip file provided. If someone did get it working, I'd want to hear more about it.
Currently, for me, I hacked a stripped down equivalent of it which lists and shows passwords in pure Python, and the damn thing runs on Windows. See https://github.com/guilt/lastpass-python/ if anybody came here in the hope of getting something to run.
@ed-alertedh I'm trying to build with msys now, but getting the following error: /agent.c:46:10: fatal error: sys/socket.h: No such file or directory 46 | #include <sys/socket.h>
How did you manage to work around that when you compiled?
Edit: nevermind, I was using the wrong environment.
I managed to get a new version compiled: lpass.zip
@rogerfar Could you compile a static binary as well?
This is the first time I compiled something on Linux ever, so if someone tells me how that works, then gladly.
@rogerfar Usually I'd pass -static -static-libgcc
(and optionally -static-libstdc++
if C++)
Finally, I'd verify what DLLs the exe depends on (I'd use use dumpbin -dependents lpass.exe
)
I suppose people have already done this, but if you are content with installing wsl2 (windows 2004 or later), I found this works well enough for me to get the password from lpass running in ubuntu (or whatever) into the windows clipboard without leaving my powershell prompt.
wsl lpass show -p work/email | clip.exe
I'm trying to follow @christianrondeau's instruction, but I'm getting the following error... anyone know what's up?
troy@OKC-TKNAPP:/c/Users/tknapp/bin/lastpass-cli$ cmake . && make
: not foundVERSION-GEN: 2: ./LASTPASS-VERSION-GEN:
: not foundVERSION-GEN: 8: ./LASTPASS-VERSION-GEN:
: not foundVERSION-GEN: 11: ./LASTPASS-VERSION-GEN:
-- Generating donee
-- Build files have been written to: /c/Users/tknapp/bin/lastpass-cli
[ 2%] Building C object CMakeFiles/lpass.dir/blob.c.o
/c/Users/tknapp/bin/lastpass-cli/blob.c:42:10: fatal error: version.h: No such file or directory
#include "version.h"
compilation terminated.
CMakeFiles/lpass.dir/build.make:86: recipe for target 'CMakeFiles/lpass.dir/blob.c.o' failed
make[2]: *** [CMakeFiles/lpass.dir/blob.c.o] Error 1
make[1]: *** [CMakeFiles/lpass.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
OK So what about the corporate users with a 1604 (ATM) build of Windows 10, that does not have the computer capacity to install Cygwin, and absolutely need a LastPass cli for Windows? All this talk and someone could have built one by now, but instead I see a lot of attempts, with different hacks/workarounds instead of a final solution.
Does Lastpass not employ any Windows developers? Is there no one on this planet that can possibly do this? Why isn't Lastpass knocking on every door looking for someone who can do this? My firm pays a lot of money for LastPass and so we are demanding that there be some real movement be made on this front. This isn't some random open source project, it is an enterprise application used by millions.
/rant
Any news on this?
For those looking for a proper Windows CLI, a Powershell module seems to be the best bet, as it is included and integrated into Windows. Accordingly, looking on the Powershell Gallery, there look to be some options available:
While none of these seem to be a full replacement for the lastpass-cli project, hopefully these projects provide some suitable alternatives.
@ImIOImI Getting the same error while trying to compile the source code in windows using cygwin. No version.h file is present. Unable to execute the LASTPASS-VERSION-GEN as well. Was anyone able to install and get it to work on windows?
@ImIOImI Getting the same error while trying to compile the source code in windows using cygwin. No version.h file is present. Unable to execute the LASTPASS-VERSION-GEN as well. Was anyone able to install and get it to work on windows?
put this in the version.h file
@sjlouder 's options are as good as we're going to get so I'm closing this. It's been so long we're planning to leave LastPass anyway now. :)
Understand if Windows support needs to be a fork, but I would imagine there are very few LastPass users who don't ever use Windows, even if only for corporate email and the like. :)