Skip to content

Instantly share code, notes, and snippets.

@kitaro-tn kitaro-tn/ssh
Last active Jul 18, 2018

What would you like to do?
ssh control socket port foward

SSHでcontrol socketを利用したport foward

  • mysql hostをport foward
ssh -M -S ctl_path -Nf -L 33306:db-instance:3306 ec2-user@ -i ~/.ssh/aws.pem
  • control socketをチェック
ssh -S ctl_path -O check ec2-user@
  • control socketを終了
ssh -S ctl_path -O exit ec2-user@

おまけ: mysqlの結果を配列で受け取る

result=$(mysql -u user -h -P 33306 -ppass dbname -N -se "SELECT id, name FROM member LIMIT 1")
IFS=$'\t' read -ra columns <<< result
echo "id: ${columns[0]}"
echo "name: ${columns[1]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.