UbuntuHelp:UbuntuLTSP/PasswordlessSSH
来自Ubuntu中文
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
This page should apply to any Ubuntu version |
If you find this information not applicable to some versions/releases, please edit this page and modify this header to reflect that. Please also include any necessary modifications for this information to apply to the additional versions.
Introduction
Passwordless SSH is a method to login to remote computers by using SSH keypairs, thus avoiding the need to enter a password. It can be handy for remote-controlling LTSP clients, e.g. for rebooting or troubleshooting them. There are many variations on how to setup passwordless SSH. In the method described here, the server's public SSH key is copied to the authorized keys of the chroot's root account. This way, anyone that has root access to the server, and is able to access the server's private SSH key, will also have root access to the clients.
Implementation
To install openssh-server and copy the server's public SSH key to all of your chroots, issue the following commands:
for ROOT in /opt/ltsp/*/root; do sudo LTSP_HANDLE_DAEMONS=false chroot "${ROOT%/root}" apt-get --yes install openssh-server sudo mkdir -p "$ROOT/.ssh" sudo chmod 700 "$ROOT/.ssh" sudo cp /etc/ssh/ssh_host_rsa_key.pub "$ROOT/.ssh/authorized_keys" sudo chmod 644 "$ROOT/.ssh/authorized_keys" sudo ltsp-update-image --arch $(echo "$ROOT" | cut -d'/' -f4) done
Usage
After the clients are rebooted, you should be able to control the clients by using /etc/ssh/ssh_host_rsa_key as the identity file. For example, to login as root on a client, run:
sudo ssh -i /etc/ssh/ssh_host_rsa_key 10.160.31.123
To shutdown a client, run:
sudo ssh -i /etc/ssh/ssh_host_rsa_key 10.160.31.123 poweroff
See Also
- UbuntuLTSP - Community Ubuntu LTSP Documentation.
External Links
- Password-less logins with OpenSSH - An article about passwordless SSH from the Debian Administration website.