Forgot to add README.SSH to the repo.
[libpwmd.git] / README.SSH
blobbf1b664233eae48fc0907fec301d0344e2d13725
1 Beginning with version 6 of libpwmd remote access to a pwmd server using
2 libssh2 has been available. The functions pwmd_ssh_connect() and
3 pwmd_ssh_connect_async() are used to connect to the server. After resolving
4 the hostname and connecting, an ssh session is created and the hostkey is
5 verified against a file containing known hosts. Note that only public key
6 authentication is supported and without a passphrase.
8 After verification succeeds, a channel is opened which spawns a shell. This
9 shell should execute a proxy to the pwmd server by connecting to the local
10 socket. I use 'socat', it's really handy.
12 In order to get this to work you need to put the following in your
13 ~/.ssh/authorized_keys file on the machine running the ssh and pwmd server. It
14 should be prepended to the public key portion of the private key that your
15 libpwmd client will use:
17     command="socat UNIX-CONNECT:$HOME/.pwmd/socket -"
19 Now when libpwmd spawns the SSH shell, 'socat' will read the stdout of the SSH
20 shell and redirect it to the pwmd socket. The output of pwmd works the same:
21 redirecting pwmd's socket output to the stdin of the SSH shell and back to the
22 libpwmd client.
24 You can use pwmc to try it out:
26     # Get the ssh servers public key. Make sure the hostname is correct and
27     # not hijacked when getting the hostkey. This step is optional. It can be
28     # done for you when you first connect to the host.
29     pwmc --get-hostkey --host hostname > host_file
31     # Generate an SSH key that the client will use. Then copy the contents of
32     # the generated public key to the SSH servers authorized_keys file and
33     # prepend the above mentioned line to it. You will need both the generated
34     # public and private keys when connecting to the server.
35     ssh-keygen -f keyfile
37     # If you have an ssh agent running, do the following:
38     ssh-add keyfile
40     # List the contents of the pwmd 'datafile' on the remote SSH server by
41     # connecting as the specified 'user'. If you have an ssh agent running and
42     # did the above command, you can omit the keyfile argument to the --url
43     # option.
44     echo list | pwmc --url ssh://user@hostname,keyfile datafile
46 Ben Kibbey <bjk@luxsci.net>
47 http://pwmd.sourceforge.net/