0

I'm trying to make a script to log me into my server via ssh and run programs via X11 Forwarding. I currently do this with:

ssh -XC USER@SERVER

but I also want it to log in with my password. I recently found the command sshpass but I can't find anything about it doing X11 forwarding.

What would be the best way to approach this?

Thanks

1 Answers1

1

sshpass is used this way, ie. you have to run an actual ssh command via sshpass. In your case it will be:

sshpass -p password ssh -XC USER@SERVER

So sshpass by itself doesn't have to know anything about X forwarding, because ssh handles that. The only job sshpass does is provide the password to ssh.

Please be aware that specifying a password on the command line (like in the example above) is insecure. sshpass offers alternative methods to provide a password: from file or from an environment variable (details in link).

However, the best method to use ssh without having to type a password is to configure key-based authentication, as @user68186 mentioned. Here is a tutorial how to do that.

raj
  • 10,353