My problem is that I want to log into a server that does not have a password and requires a private key.
I want to use SSHEx because it returns a pid that I can pass around and (hopefully) perform file manipulation etc. If there is a way to easily do ssh and do file manipulation with a different library I am open to all suggestions.
I have the private key and I can log in using System.cmd.
Would it be possible for you to try SSHKit rather than SSHEx?
It is more recently updated, and I believe the usage is somewhat straight forward. I donāt do anything special to make use of private keys.
To be clear, Iām asking if anyone knows working syntax to authenticate with SSH and specify the directory of the private key.
Iāve mulled over libraries and documentation and I canāt figure it out. Supposedly all these libraries do it but none of them are explicit as the node.js library I mentioned.
I assume it would be something simple like: Fake example: SSHLib host: whatever.com private_key_dir: .ssh/whatever
Beloq is a working sytnax example for how to do it with the System.cmd:
I think the key is, SSHKit and others automatically discover it, as it should be in a āwell knownā location. This is why thereās very little documetation on finding/setting it.
I see that, if you needed to specify a location other than ~/.ssh, there is at least this module:
Documentation is there on how to set up the location , which can then be fed to SSHKit.
The solution you marked as good for you is a simpler approach, but librarian did not work in my use case. I hope it fits your needs.
Very interesting topic. I was looking for a ssh package just recently, but havenāt found what I was looking for. Does anyone know if there is a ssh package which supports multiplexing of an existing connection?
Interesting question.
I focused on connecting to dozens of machines in parallel. Hadnāt looked into multiplexing into the same machine.
The base Erlang ssh facilities handle that, but I havenāt found how to do it with SSHKit.
My question would be, same application, or separate applications or instances?
The erlang :ssh facilties, within the same process allow for:
That will establish five channels to the same connection reference and make five separate calls (could do this asnyc as well). If you look at netstat for tcp with port 22, youāll see that only one connection was established.
It would be possible, if this were a networked solution, to register that connection_ref globally for the hostname, so that it could be used by any process that needs to make a ssh connection to the registered host. If set up supervised, then it would be possible for the connection to be re-established if subsequently disconnecetd.
Not a package, but possibly an approach for you, depending on your needs.
Thanks for this. I have another question. I donāt understand how you derived that answer from that portion of the documentation. If I knew how to read the docs it would save me a lot of time but they look so cryptic, I just end up asking questions.
How exactly did you derive that answer from that portion of the docs?
Do you already know Erlang?
I know this sounds like a stupid question but Iāve never had this problem with Node/JS.