SSHを用いた転送

来源:互联网 发布:c语言 strlen 编辑:程序博客网 时间:2024/05/21 09:12
rsyncを使用する場合、SSHを用いたセキュアな転送を推奨します。
以下の設定を行い、パスワード無しのSSH転送を行います。

(1) 鍵の生成
[root@localhost tmp]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):enterキー
Enter passphrase (empty for no passphrase):enterキー
Enter same passphrase again:enterキー
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
db:d5:4d:8c:b1:bf:3d:3f:3b:26:d3:bf:d2:82:b8:28 root@localhost
以上の操作で/root/.ssh に、秘密鍵「id_dsa」と公開鍵「id_dsa.pub」 というファイルが生成されます。

(2) 鍵の配置

公開鍵を公開先サーバにコピーします。
[root@localhost tmp]# scp -p /root/.ssh/id_dsa.pub 公開先サーバのIPアドレス:/root/.ssh/

公開先サーバのホスト上でコピーした公開鍵を~/.ssh/authorized_keys に追加します。
[root@www ~]# cd /root/.ssh
[root@www .ssh]# cat id_dsa.pub >> authorized_keys
[root@www .ssh]# rm id_dsa.pub
[root@www .ssh]# chmod 600 authorized_keys

(3) 転送コマンドの実行と確認
コマンドを実行し、転送の確認を行います。
[root@localhost ~]# /usr/local/bin/rsync -a --delete --bwlimit=2048 --timeout=120 -e ssh /usr/local/ZoomSight/dictionary/ <公開先サーバのユーザ>@<公開先サーバアドレス>:<公開先サーバのディレクトリパス>
The authenticity of host 'xxx.xxx.x.x (xxx.xxx.x.x)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:x: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 'xxx.xxx.x.x' (RSA) to the list of known hosts.

[root@localhost ~]#

再度、同じコマンドを実行し、認証確認と警告メッセージが出力されないことを確認します。
[root@localhost ~]# /usr/local/bin/rsync -a --delete --bwlimit=2048 --timeout=120 -e ssh /usr/local/4ucms/website/ <公開先サーバのユーザ>@<公開先サーバアドレス>:<公開先サーバのディレクトリパス>
[root@localhost ~]#

以上で設定は終了です。これでプロキシサーバから音声変換サーバへパスワード無しのSSH転送が可能となります。
0 0
原创粉丝点击