I want to be able to use the JSch Java SSH library to connect to my EC2 instance. How do I use my .pem keypair from AWS with JSch? How do I deal with the UnknownHostKey error when attempting to connect?
相关问题
- JQ: Select when attribute value exists in a bash a
- JavaScript File Transfer SSH
- Check whether the path exists on server or not in
- How to upgrade/install Upstart deamon version 1.5
- Why does this bash script work at console but fail
相关文章
- Check if directory exists on remote machine with s
- Git Clone Fails: Server Certificate Verification F
- I cannot locate production log files on Elastic Be
- Test if File/Dir exists over SSH/Sudo in Python/Ba
- Can't access AWS CodeCommit with SSH
- AWS - Configuring access to EC2 instance from Bean
- Error: “The security token included in the request
- Ansible Timeout (12s) waiting for privilege escala
1: copy ec2.pem file to ~/.ssh/
2: then chmod 700 ~/.ssh/ec2.pem
3: create a new file ~/.ssh/config
4: Now use the command with ssh and Host value you given in ~/.ssh/config file's first line. like this
5: Now use the step 4 command in your code
The groovy code will use the JSch library to connect to an EC2 instance, run the whoami and hostname commands, then print the results to the console:
Here's another example of how to make the same connection, but through a gateway ssh tunnel (NAT bastion): https://gist.github.com/scoroberts/5605655