#!/bin/bash # $ ssh-keygen -t rsa -b 2048 -C you_comment_here -f filename # create user with ssh public key # 20140214 username=‘yourname‘ useradd ${username} id ${username} [ -d /home/${username}/.ssh ] || mkdir -p /home/${username}/.ssh cat <<_PUBKEY >> /home/${username}/.ssh/authorized_keys your public key _PUBKEY chmod 700 /home/${username}/.ssh chmod 600 /home/${username}/.ssh/authorized_keys chown -R ${username}:${username} /home/${username}/.ssh cat /home/${username}/.ssh/authorized_keys
时间: 2024-10-06 06:00:51