-
Notifications
You must be signed in to change notification settings - Fork 4
sshポートフォワーディング専用ユーザを作成してみる
mechamogera edited this page Sep 26, 2012
·
5 revisions
- Amazon Linuxでec2-userで作業
- ユーザ作成
$ sudo useradd hoge
- ssh用の鍵作成
$ sudo su - hoge
$ ssh-keygen -t rsa
# => デフォルトで設定
$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys
$ exit
$ sudo cp /home/hoge/.ssh/id_rsa .
$ sudo chown ec2-user.ec2-user id_rsa
- rbash準備
$ sudo ln -s /bin/bash /bin/rbash
$ sudo vi /etc/shells
# => /bin/rbashを追加
- ユーザにrbash設定
$ sudo chsh -s /bin/rbash hoge
$ sudo su - hoge
$ rm .bash*
$ exit
$ echo 'export PATH=$HOME/bin' | sudo tee /home/hoge/.bash_profile
$ sudo chown root.root /home/hoge/.bash_profile
$ sudo chmod 644 /home/hoge/.bash_profile
- ssh用の鍵をとってきてhogeユーザでアクセス => OK
- ほとんど何もできない
- hogeユーザでポートフォワーディング => OK