Adding Authorized SSH Keys Using Ansible

You can easily manage and deploy multiple public SSH keys per user using Jinja templating within an Ansible playbook. Variable Definition (vars.yml) vars: ssh_user_key: - user: ritesh exclusive: no keys: - ritesh.centos - ritesh.fedora Ansible Task - name: Upload user authorized SSH keys authorized_key: user: "{{ item.user }}" exclusive: "{{ item.exclusive if item.exclusive is defined else 'no' }}" key: "{% for file_name in item['keys'] %}{{ lookup('file', file_name) }}{% if not loop.last %}{{ '\n' }}{% endif %}{% endfor %}" become: yes become_user: "{{ item.user }}" with_items: - "{{ ssh_user_key }}" tags: - setup-user-ssh-client-key

June 22, 2016 · 1 min

Closing a Hung SSH Session

How does one close an SSH session that has hung or disconnected from the server? Use the key sequence ~. (tilde followed by a dot, typed at the beginning of a new line). For more information, check the SSH manual: man ssh Background I was happily working on my system, accessing my test box remotely. Suddenly, there was darkness—or what most people call a power outage. Since my UPS was in the repair shop, my machine shut down and left me with a frozen SSH session upon rebooting and reconnecting.

November 21, 2008 · 1 min