I want to automate ssh using the expect command!

Introduction

As mentioned in the title, aiming to automate ssh using the expect command Write an article.

Specific goals

Automate ssh connection to vagrant currently on your device And even some confirmation commands are automated.

I referred to the following article for the goal. https://qiita.com/ine1127/items/cd6bc91174635016db9b#comments

① Thinking error

Since my motto is to think while moving my hands, I will write a command for the time being.

#!/bin/sh

expect -c "
set timeout 5
spawn vagrant /usr/bin/ssh 
expect \"$\"
exit 
"

The result didn't go well ...

spawn vagrant /usr/bin/ssh I think the above expression is strange, I don't know what to do specifically. .. ..

② Thinking error

I'm not sure, but instead of entering with vagrant ssh There are many cases of ssh connection with IP address, and I expect that it will work. ..

cat Vagrantfile 
config.vm.network "private_network", ip: "192.168.33.10"

Check the IP address and start SSH connection! !!

ssh 192.168.33.10
192.168.33.10: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Remorse ... If you google lightly, it seems that the authority relationship is the cause, but ... Due to lack of knowledge, it ends today. ..

Recommended Posts

I want to automate ssh using the expect command!
I want to automate ssh using the expect command! part2
I want to increase the security of ssh connections
I want to pin Spyder to the taskbar
I want to output to the console coolly
I tried to summarize the umask command
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to display the progress bar
I want to connect remotely to another computer, and the nautilus command
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to leave an arbitrary command in the command history of Shell
I want to email from Gmail using Python.
I want to visualize csv files using Vega-Lite!
I want to handle the rhyme part7 (BOW)
[I want to classify images using Tensorflow] (2) Let's classify images
I want to customize the appearance of zabbix
I want to use the activation function Mish
I want to display the progress in Python!
I want to be notified when the command operation is completed on linux!
I want to see the file name from DataLoader
How to write a GUI using the maya command
I want to grep the execution result of strace
less command I want to definitely remember this [linux command]
I want to inherit to the back with python dataclass
I want to fully understand the basics of Bokeh
I tried to approximate the sin function using chainer
I made a command to markdown the table clipboard
I want to publish the product at the lowest cost
I tried to identify the language using CNN + Melspectogram
I want to use the R dataset in python
I tried to complement the knowledge graph using OpenKE
I want to handle the rhyme part8 (finished once)
I tried to compress the image using machine learning
I want to take a screenshot of the site on Docker using any font
I want to extract only pods with the specified label using Label Selector in Client-go
I want to use Linux commands at the command prompt! Use Linux commands at the command prompt instead of Git Bash
Clone using the dd command
I want to solve Sudoku (Sudoku)
[TensorFlow] I want to master the indexing for Ragged Tensor
I want to initialize if the value is empty (python)
I want to save the photos sent by LINE to S3
maya Python I want to fix the baked animation again.
I want to move selenium for the time being [for mac]
I tried to simulate ad optimization using the bandit algorithm.
I want to start a jupyter environment with one command
I want to use only the normalization process of SudachiPy
I want to get the operation information of yahoo route
I want to change the Japanese flag to the Palau flag with Numpy
[Python] I want to use the -h option with argparse
[TF] I tried to visualize the learning result using Tensorboard
I want to know the features of Python and pip
I want to map the EDINET code and securities number
Keras I want to get the output of any layer !!
I want to align the significant figures in the Numpy array
I want to know the legend of the IT technology world
I tried to approximate the sin function using chainer (re-challenge)
I want to create a Dockerfile for the time being.
I tried to output the access log to the server using Node.js