Last active
September 6, 2019 17:59
-
-
Save stiakov/7c06480321adec26a3a1d1e7df428320 to your computer and use it in GitHub Desktop.
Revisions
-
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ According to your $SHELL, use the proper file, in my case I'm using **ZSH** so I 1. Export your password as an environment variable: `$ echo "export hid_pass='p455word'"` 2. Update your $Shell after every modification: -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -71,7 +71,7 @@ Create an alias to run the connection within preset args. 1. Add your alias to your $SHELL (.zshrc / .bashrc): `$ echo "alias mycon='~/my_connection.exp 192.168.0.100 root $hid_pass'"` 2. Don't forget to update the $SHELL after every modification: -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -75,8 +75,8 @@ Create an alias to run the connection within preset args. 2. Don't forget to update the $SHELL after every modification: `$ exec $SHELL` or `$ source ~/.zshrc` 3. Call the connection using your alias, and wait until the connection is done: `$ mycon` -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 13 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,11 +10,11 @@ You need **expect** scripting language to run this task. # Setup 1. Create a file that will store your _expect script_: `$ touch ~/my_connection.exp` 2. Edit your file in your favorite editor: ``` #!/usr/bin/expect @@ -36,11 +36,11 @@ send "$password\r"; interact ``` 3. Modifiy permissions to your _expect script_: `$ chmod +x ~/my_connection.exp` 4. Run your script using arguments like this, use your own args: `$ ~/my_connection.exp 192.198.0.100 root p455w0rd` @@ -53,30 +53,30 @@ Avoid to expose your password exporting it from your **.zshrc** / **.bashrc**. According to your $SHELL, use the proper file, in my case I'm using **ZSH** so I'll edit my **~/.zshrc**. 1. Export your password as an environment variable: `echo "$ export hid_pass='p455word'"` 2. Update your $Shell after every modification: `$ exec $SHELL` or `$ source ~/.zshrc` 3. Use your script without exposing your password: `$ ~/my_connection.exp 192.168.0.100 root $hid_pass` ## Run your connection with a couple keystrokes Create an alias to run the connection within preset args. 1. Add your alias to your $SHELL (.zshrc / .bashrc): * `$ echo "alias mycon='~/my_connection.exp 192.168.0.100 root $hid_pass'"` 2. Don't forget to update the $SHELL after every modification: * `$ exec $SHELL` or `$ source ~/.zshrc` 3. Call the connection using your alias, and wait until the connection is done: * `$ mycon` -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,19 @@ ## Requirements You need **expect** scripting language to run this task. - In debian based distros run: `$ sudo apt install expect` - In MacOS: `$ brew install expect` # Setup 1 Create a file that will store your _expect script_: `$ touch ~/my_connection.exp` 2 Edit your file in your favorite editor: ``` #!/usr/bin/expect @@ -36,7 +36,7 @@ send "$password\r"; interact ``` 3 Modifiy permissions to your _expect script_: `$ chmod +x ~/my_connection.exp` @@ -51,11 +51,11 @@ interact Avoid to expose your password exporting it from your **.zshrc** / **.bashrc**. According to your $SHELL, use the proper file, in my case I'm using **ZSH** so I'll edit my **~/.zshrc**. 1 Export your password as an environment variable: `echo "$ export hid_pass='p455word'"` 2 Update your $Shell after every modification: @@ -73,7 +73,7 @@ Create an alias to run the connection within preset args. `$ echo "alias mycon='~/my_connection.exp 192.168.0.100 root $hid_pass'"` 2 Don't forget to update the $SHELL after every modification: `$ exec $SHELL` or `$ source ~/.zshrc` -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -49,34 +49,34 @@ interact ## Hide your pass Avoid to expose your password exporting it from your **.zshrc** / **.bashrc**. According to your $SHELL, use the proper file, in my case I'm using **ZSH** so I'll edit my **~/.zshrc** 1 Export your password as an environment variable: `echo "export hid_pass='p455word'"` 2 Update your $Shell after every modification: `$ exec $SHELL` or `$ source ~/.zshrc` 3 Use your script without exposing your password: `$ ~/my_connection.exp 192.168.0.100 root $hid_pass` ## Run your connection with a couple keystrokes Create an alias to run the connection within preset args. 1 Add your alias to your $SHELL (.zshrc / .bashrc): `$ echo "alias mycon='~/my_connection.exp 192.168.0.100 root $hid_pass'"` 2 Don't forget to update your $SHELL after every modification: `$ exec $SHELL` or `$ source ~/.zshrc` 3 Call the connection using your alias, and wait until the connection is done: `$ mycon` -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ According to your shell, use the proper file, in my case I'm using **ZSH** so I' 1 Export your password to an environment constant `echo "export hid_pass='p455word'"` 2 Update your $Shell after every modification -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -78,4 +78,5 @@ Create an alias to run the connection within preset args `$ exec $SHELL` or `$ source ~/.zshrc` 3 Call the connection using your alias, and wait until the connection is done `$ mycon` -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 16 additions and 14 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,20 @@ # Automatize your remote logins through ssh ## Requirements You need `expect` scripting language to run this task - In debian based distros run `$ sudo apt install expect` - In MacOs `brew install expect` # Setup 1 Create a file that will store your _expect script_. `$ touch ~/my_connection.exp` 2 Edit your file in your favorite editor. ``` #!/usr/bin/expect @@ -35,14 +36,15 @@ send "$password\r"; interact ``` 3 Modifiy permissions to your _expect script_ `$ chmod +x ~/my_connection.exp` 4 Run your script using arguments like this, use your own args: `$ ~/my_connection.exp 192.198.0.100 root p455w0rd` # Customizing (Optional) ## Hide your pass @@ -51,29 +53,29 @@ Avoid to expose your password exporting it from your .zshrc / .bashrc According to your shell, use the proper file, in my case I'm using **ZSH** so I'll edit my **~/.zshrc** 1 Export your password to an environment constant `echo "alias hid_pass='p455word'"` 2 Update your $Shell after every modification `$ exec $SHELL` or `$ source ~/.zshrc` 3 Use your script without exposing your password `$ ~/my_connection.exp 192.168.0.100 root $hid_pass` ## Run your connection with a couple keystrokes Create an alias to run the connection within preset args 1 Add your alias to your $Shell (.zshrc / .bashrc) `$ echo "alias mycon='~/my_connection.exp 192.168.0.100 root $hid_pass'"` 2 Don't forget to update your $Shell after every modification `$ exec $SHELL` or `$ source ~/.zshrc` 3 Call the connection using your alias, and wait until the connection is done `$ mycon` -
Santiago Torres revised this gist
Sep 6, 2019 . 1 changed file with 36 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,4 +41,39 @@ interact - Run your script using arguments like this, use your own args: `$ ~/my_connection.exp 192.198.0.100 root p455w0rd` # Customizing (Optional) ## Hide your pass Avoid to expose your password exporting it from your .zshrc / .bashrc According to your shell, use the proper file, in my case I'm using **ZSH** so I'll edit my **~/.zshrc** - Export your password to an environment constant `echo "alias hid_pass='p455word'"` - Update your $Shell after every modification `$ exec $SHELL` or `$ source ~/.zshrc` - Use your script without exposing your password `$ ~/my_connection.exp 192.168.0.100 root $hid_pass` ## Run your connection with a couple keystrokes Create an alias to run the connection within preset args - Add your alias to your $Shell (.zshrc / .bashrc) `$ echo "alias mycon='~/my_connection.exp 192.168.0.100 root $hid_pass'"` - Don't forget to update your $Shell after every modification `$ exec $SHELL` or `$ source ~/.zshrc` - Call the connection using your alias, and wait until the connection is done `$ mycon` -
Santiago Torres created this gist
Sep 6, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #Automatize your remote logins through ssh ##Requirements You need `expect` to run this task - In debian based distros run `$ sudo apt install expect` - In MacOs `brew install expect` # Setup Create a file that will store your _expect script_. - `$ touch ~/my_connection.exp` - Edit your file in your favorite editor. ``` #!/usr/bin/expect set timeout 5 set ip [lindex $argv 0] set user [lindex $argv 1] set password [lindex $argv 2] spawn ssh "$user\@$ip" expect "Password:" send "$password\r"; interact ``` - Modifiy permissions to your _expect script_ `$ chmod +x ~/my_connection.exp` - Run your script using arguments like this, use your own args: `$ ~/my_connection.exp 192.198.0.100 root p455w0rd`