==========
chibi_sshd
==========


.. image:: https://img.shields.io/pypi/v/chibi_sshd.svg
        :target: https://pypi.python.org/pypi/chibi_sshd

.. image:: https://readthedocs.org/projects/chibi-sshd/badge/?version=latest
        :target: https://chibi-sshd.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status




package for handling config files of ssh like sshd_config and authorized_keys


* Free software: WTFPL
* Documentation: https://chibi-sshd.readthedocs.io.


=======
Install
=======


.. code-block:: bash

	pip install chibi-fstab


=====
Usage
=====


.. code-block:: bash

	cat > /etc/ssh/ssh_config << 'endmsg'
	AuthorizedKeysFile .ssh/authorized_keys
	PasswordAuthentication yes
	ChallengeResponseAuthentication no
	UsePAM yes
	PrintMotd no
	UseDNS no
	Subsystem sftp	/usr/lib/ssh/sftp-server
	AllowUsers Misuzu
	endmsg

.. code-block:: python

	from chibi_sshd import Chibi_sshd_conf, Chibi_authorized_keys
	from chibi.file import Chibi_path

	default_file = = Chibi_sshd_conf.default
	assert default_file.path == '/etc/ssh/sshd_config'
	config = default_file.read()
	assert isinstance( config.PasswordAuthentication, bool )
	assert config.PasswordAuthentication
	config.PasswordAuthentication = False
	default_file.write( config )
	assert "PasswordAuthentication no" in default_file

	authorized_keys = Chibi_authorized_keys(
		'/home/Misuzu/.ssh/authorized_keys' )
	id_rss_pub = Chibi_path(
		'/home/Misuzu/.ssh/id_rss.pub' ).open().read()
	if id_rss_pub not in authorized_keys:
		authorized_keys.append( id_rss_pub )
	assert id_rss_pub in authorized_keys:
