ssh 及び sshd のセットアップ(revision32) Cygwin セットアップ ssh 及び sshd のセットアップ Create 25. Jun. 2011 Update 25. Jun. 2011 Revision 32 Author Akira 1/10 ssh 及び sshd のセットアップ(revision32) Index Chapter1Cygwin のインストール.........................................................................................................3 1.1Cygwin setup のダウンロード....................................................................................................3 1.2sshd のインストール...................................................................................................................3 Chapter2 ユーザー側の設定..............................................................................................................4 2.1Cygwin の起動..........................................................................................................................4 2.2RSA キーの作成.......................................................................................................................4 2.3RSA キーの転送.......................................................................................................................5 2.4 対象のホストへアクセスする.....................................................................................................5 Chapter3 サーバーの起動..................................................................................................................6 3.1 サーバのセットアップ................................................................................................................6 3.2 コンフィグファイルの編集.........................................................................................................8 3.3authorized_keys を追加する......................................................................................................8 3.4 サーバーの起動.......................................................................................................................8 Chapter4Appendix .............................................................................................................................9 4.1 サービスの削除........................................................................................................................9 Chapter5Contact................................................................................................................................10 2/10 ssh 及び sshd のセットアップ(revision32) Chapter1 Cygwin のインストール 1.1 Cygwin setup のダウンロード http://www.cygwin.com もしくは、cygwin で検索し、setup.exe をダウンロードして実行する cygwin のセットアップは、後からパッケージを追加する事も出来る 1.2 sshd のインストール cygwin 自体のインストールは別のドキュメント (http://www.akiron.com/FPGA/cygwinsetup.pdf)を読む事 ここでは、select package で net->openssh を選ぶ事 図 1.1:Open SSH セレクト Cygwin のインストール 3/10 ssh 及び sshd のセットアップ(revision32) Chapter2 ユーザー側の設定 2.1 Cygwin の起動 Cygwin アイコンをダブルクリックして起動する 図 2.1:cygwin の起動画面 2.2 RSA キーの作成 Cygwin コマンドラインから、次のコマンドを打ち込む ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key ( /home/akira/.ssh/id_rsa): ← そのまま Enter Enter passphrase ( empty for no passphrase): ← 自分のパスワードを入力 Enter same passphrase again: ← 同じパスワードを入力 ユーザー側の設定 4/10 ssh 及び sshd のセットアップ(revision32) 2.3 RSA キーの転送 RSA キーは接続先のホストに「私はアクセスします、了解して下さい」という為に使う ~/.ssh/id_rsa.pub と言うファイルがあるので、これをアクセスしたいサーバーの管理者に送る サーバ管理者が登録すると、アクセスできるようになる 図 2.2:id_rsa.pub ファイル 2.4 対象のホストへアクセスする 対象のホストへは cygwin 等からアクセスする 初回だけ聞かれるの で yes とする cygwin からのアクセスは、以下の通り ssh [email protected] The authenticity of host '172.16.80.70 (172.16.80.70)' can't be established. ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.16.80.70' (ECDSA) to the list of known hosts. Enter passphrase for key '/home/akira/.ssh/id_rsa': ← 自分で作成したパスワード Last login: Sat Jun 25 21:58:15 2011 from akira-pc ログインに成功すると、リモートの PC にコマンドラインでアクセスできる ユーザー側の設定 5/10 ssh 及び sshd のセットアップ(revision32) Chapter3 サーバーの起動 ※1 サーバーの削除に失敗した場合は、appendex を参照 3.1 サーバのセットアップ Ssh-host-config コマンドを使用する ssh-host-config *** Info: Generating /etc/ssh_host_key *** Info: Generating /etc/ssh_host_rsa_key *** Info: Generating /etc/ssh_host_dsa_key *** Info: Generating /etc/ssh_host_ecdsa_key *** Info: Creating default /etc/ssh_config file *** Info: Creating default /etc/sshd_config file *** Info: Privilege separation is set to yes by default since OpenSSH 3.3. *** Info: However, this requires a non-privileged account called 'sshd'. *** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep. *** Query: Should privilege separation be used? (yes/no)yes ← yes と返答 *** Info: Note that creating a new user requires that the current account have *** Info: Administrator privileges. Should this script attempt to create a *** Query: new local account 'sshd'? (yes/no) yes ← yes と返答 *** Warning: Creating the user 'sshd' failed! *** Warning: Couldn't create user 'sshd'! *** Warning: Privilege separation set to 'no' again! *** Warning: Check your /etc/sshd_config file! *** Info: Updating /etc/sshd_config file *** Warning: The following functions require administrator privileges! *** Query: Do you want to install sshd as a service? *** Query: (Say "no" if it is already installed as a service) (yes/no)yes ← yes と返答 *** Query: Enter the value of CYGWIN for the daemon: [] ← enter のみ サーバーの起動 6/10 ssh 及び sshd のセットアップ(revision32) *** Info: On Windows Server 2003, Windows Vista, and above, the *** Info: SYSTEM account cannot setuid to other users -- a capability *** Info: sshd requires. You need to have or to create a privileged *** Info: account. This script will help you do so. *** Info: You appear to be running Windows XP 64bit, Windows 2003 Server, *** Info: or later. On these systems, it's not possible to use the LocalSystem *** Info: account for services that can change the user id without an *** Info: explicit password (such as passwordless logins [e.g. public key *** Info: authentication] via sshd). *** Info: If you want to enable that functionality, it's required to create *** Info: a new account with special privileges (unless a similar account *** Info: already exists). This account is then used to run these special *** Info: servers. *** Info: Note that creating a new user requires that the current account *** Info: have Administrator privileges itself. *** Info: No privileged account could be found. *** Info: This script plans to use 'cyg_server'. *** Info: 'cyg_server' will only be used by registered services. *** Query: Do you want to use a different name? (yes/no)no ← no を入力 *** Query: Create new privileged user account 'cyg_server'? (yes/no) yes ← yes を入力 *** Info: Please enter a password for new user cyg_server. Please be sure *** Info: that this password matches the password rules given on your system. *** Info: Entering no password will exit the configuration. *** Query: Please enter the password: ← パスワードを入力 *** Query: Reenter: ← 再入力 *** Warning: Something went wrong installing the sshd service. サーバーの起動 7/10 ssh 及び sshd のセットアップ(revision32) *** Info: Host configuration finished. Have fun! 3.2 コンフィグファイルの編集 /etc/sshd_config を編集する PasswordAuthentication no を追加する ChallengeResponseAuthentication no を追加する 3.3 authorized_keys を追加する ~/.ssh/authorized_keys 上記のファイル(なければ作成)にアクセス要求のあったユーザーからの id_rsa.pub キーファイルの内容を追加する 3.4 サーバーの起動 コマンドラインより cygrunsrv -S sshd として、サーバーを開始する この起動は一回のみで良く、次回からは PC 起動時に勝手に開始される /etc/sshd_config を再編集した場合等は、一度サービスを停止して再起動する必要がある cygrunsrv -E sshd cygrunsrv -S sshd サーバーの起動 8/10 ssh 及び sshd のセットアップ(revision32) Chapter4 Appendix 4.1 サービスの削除 Cygwin のセットアップをしている時にサービスが削除出来ない為に sshd の再インストールに 失敗する事が何度かあった この場合、以下のコマンドでサービスを削除する sc.exe delete sshd Appendix 9/10 ssh 及び sshd のセットアップ(revision32) Chapter5 Contact In many case, you get problem, even you this instruction. Tell me those problem. E-mail: [email protected] web:http://www.akiron.com/FPGA facebook:FPGA Contact 10/10
© Copyright 2026 Paperzz