scpとsshのパスワード認証を自動化
とりあえず下記で一応動いたのででメモ。 シェルのファイル作る。expectを使う。 「auto_ssh.sh」を作成#!/bin/sh expect -c " spawn scp /home/source/hall.sql ●●@●●.●●.●●.●●:/home/user/ expect { \"Enter passphrase for key '/home/user/.ssh/id_rsa':\" { send \"password\r\" } } interact " expect -c " spawn ssh ●●@●●.●●.●●.●● expect { \"Enter passphrase for key '/home/user/.ssh/id_rsa':\" { send \"password\r\" } } expect { \"/home/user/.zshrc:1: command not found: riable\" { send \"cat /home/user/hall.sql | /usr/bin/mysql -u root db -ppassword\r\" send \"logout\r\" } } interact "$ sh auto_ssh.sh