📜 ⬆️ ⬇️

Ssh. Remember the password.

Those who often connect to remote servers via ssh know that if applications such as WinSCP (Windows), Nautilus (Gnome) or Krusader (KDE) are able to remember passwords, then things are not so good with the console. Of course, sooner or later, everyone finds a solution to this problem for himself, and this is how I found it. First of all, you need to install the expect_tcl package. Then it remains only to write a small .sh script that will allow us to connect via ssh without entering a password every time. Actually, here's the code:
#! / bin / bash
expect -c ”spawn ssh $ 1 @ $ 2 -x \” $ 4 \ ”expect \” password: \ ”send \” $ 3 \ r \ ”interact“

You can call for example:
$ ./ssh.sh user host password command

or make a shortcut in the menu, like this:
gnome-terminal -x /path/to/script/ssh.sh user host password command

however, there is one drawback, the transfer of the 4th parameter, that is, the call to a remote command, does not always work. That's all.

')

Source: https://habr.com/ru/post/22093/


All Articles