Use Expect in a Bash script to provide a password to an SSH command

Mixing Bash and Expect is not a good way to achieve the desired effect. I’d try to use only Expect: #!/usr/bin/expect eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no usr@$myhost.example.com # Use the correct prompt set prompt “:|#|\\\$” interact -o -nobuffer -re $prompt return send “my_password\r” interact -o -nobuffer -re $prompt return send “my_command1\r” interact -o -nobuffer -re … Read more

How do programs like gitolite work?

gitolite in itself is an authorization layer which doesn’t need ssh. It only needs to know who is calling it, in order to authorize or not that person to do git commands. SSH is used for authentication (but you can use an Http Apache for authentication as well, for instance) The way gitolite is called … Read more

Paramiko “Unknown Server”

I experienced the same issue and here’s the solution that worked out for me: import paramiko client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(‘127.0.0.1’, username=username, password=password) stdin, stdout, stderr = client.exec_command(‘ls -l’) This is to set the policy to use when connecting to a server that doesn’t have a host key in either the system or local HostKeys … Read more

Multiple GitHub Accounts & SSH Config

Andy Lester’s response is accurate but I found an important extra step I needed to make to get this to work. In trying to get two profiles set up, one for personal and one for work, my ~/.ssh/config was roughly as follows: Host me.github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/me_rsa Host work.github.com HostName github.com PreferredAuthentications … Read more