Skip to content

Instantly share code, notes, and snippets.

@syou007
Created October 8, 2015 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syou007/5c9269424483ff75d539 to your computer and use it in GitHub Desktop.
Save syou007/5c9269424483ff75d539 to your computer and use it in GitHub Desktop.
Amazon EC2にSudoユーザーを追加する。 ref: http://qiita.com/syou007/items/f3feaa6688ce70900642
$ ssh ec2-user@xxxx -i xxx.pem
$ useradd sudo-user
$ ssh-keygen -t rsa
no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"ec2-user\" rather than the user \"root\".';echo;sleep 10" ssh-rsa XXXXXXXX
$ ssh ec2-user@xxxx -i xxx.pem
# 作成したsudoユーザーに切り替える。
$ sudo su - sudo-user
$ mkdir .ssh
$ vi .ssh/authorized_keys
$ ssh ec2-user@xxxx -i xxx.pem
$ sudo visudo
root ALL=(ALL) ALL
sudo-user ALL=(ALL) NOPASSWD:ALL
$ ssh sudo-user@xxx -i ras[さっき作った鍵]
$ sudo ls
$ sudo visudo -f /etc/sudoers.d/cloud-init
$ sudo view /etc/ssh/sshd_config
PermitRootLogin forced-commands-only
$ sudo view /root/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment