Elixir Phoenix SSH: Difference between revisions
From ElixirBlocks
								
												
				 (Created page with "These are ways to SSH into a server using Elixir/Phoenix. Using the librarian library you can do this:   <source>  SSH.connect!("test.laptop.local", username: "username", password: "passs", silently_accept_hosts: true) </source>   If server has a private key:  <source>       SSH.connect(         "server.host",         user: "server.user",         port: "server.port",         identity: "identity path eg: ~/.ssh/id_rsa_nop",         save_accepted_host: false,         silen...")  | 
				No edit summary  | 
				||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
These are ways to SSH into a server using Elixir/Phoenix. Using the   | These are ways to SSH into a server using Elixir/Phoenix. Using the '''Librarian''' library you can do this:  | ||
| Line 20: | Line 20: | ||
         user_interaction: false  |          user_interaction: false  | ||
       )  |        )  | ||
</source>  | |||
Librarian has a few SCP commands as well:  | |||
<source>  | |||
{:ok, conn} = SSH.connect("some.other.server")  | |||
SSH.send!(conn, binary_or_filestream, "path/to/destination.file")  | |||
{:ok, conn} = SSH.connect("some.other.server")  | |||
SSH.fetch!(conn, "path/to/source.file")  | |||
|> Enum.map(&do_something_with_chunks/1)  | |||
</source>  | </source>  | ||
Latest revision as of 20:27, 11 June 2024
These are ways to SSH into a server using Elixir/Phoenix. Using the Librarian library you can do this:
SSH.connect!("test.laptop.local", username: "username", password: "passs", silently_accept_hosts: true)
If server has a private key:
      SSH.connect(
        "server.host",
        user: "server.user",
        port: "server.port",
        identity: "identity path eg: ~/.ssh/id_rsa_nop",
        save_accepted_host: false,
        silently_accept_hosts: true,
        user_interaction: false
      )
Librarian has a few SCP commands as well:
{:ok, conn} = SSH.connect("some.other.server")
SSH.send!(conn, binary_or_filestream, "path/to/destination.file")
{:ok, conn} = SSH.connect("some.other.server")
SSH.fetch!(conn, "path/to/source.file")
|> Enum.map(&do_something_with_chunks/1)