Last active
December 13, 2018 08:03
-
-
Save pykong/563adcea5f268f77bbb60abd873e1c27 to your computer and use it in GitHub Desktop.
https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password
https://stackoverflow.com/questions/112396/how-do-i-remove-the-passphrase-for-the-ssh-key-without-having-to-create-a-new-ke
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Don't use a password. Generate a passphraseless SSH key and push it to your VM. | |
If you already have an SSH key, you can skip this step… Just hit Enter for the key and both passphrases: | |
$ ssh-keygen -t rsa -b 2048 | |
Generating public/private rsa key pair. | |
Enter file in which to save the key (/home/username/.ssh/id_rsa): | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /home/username/.ssh/id_rsa. | |
Your public key has been saved in /home/username/.ssh/id_rsa.pub. | |
Copy your keys to the target server: | |
$ ssh-copy-id id@server | |
id@server's password: | |
Now try logging into the machine, with ssh 'id@server', and check in: | |
.ssh/authorized_keys | |
to make sure we haven’t added extra keys that you weren’t expecting. | |
Finally check logging in… | |
$ ssh id@server | |
id@server:~$ | |
You may also want to look into using ssh-agent if you want to try keeping your | |
keys protected with a passphrase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install sshpass | |
$ sshpass -p your_password ssh user@hostname | |
- or - | |
$ sshpass -p your_password ssh -l user_name 192.168.XXX.XXX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment