Tuesday | 30 APR 2024
[ previous ]
[ next ]

Passing Passwords to SSH

Title:
Date: 2023-09-19
Tags:  windows, sysadmin

The ssh client in Windows doesn't let you pass passwords in directly and Windows doesn't support sshpass so the next best thing is to use a custom version of ssh that has a flag to pass in the password.

SSH Releases

You can place ssh.exe and libcrypto.dll in C:\bin. C:\bin is a folder I created to hold these portable executables.

Now we can create a function and an alias in the Windows Terminal profile.

Open the profile by opening powershell and typing in:

notepad $PROFILE

This will open notepad and then you can add the following lines:

function Myserver { C:\bin\ssh.exe -Z "password" username@192.168.11.11 }
Set-Alias asd Myserver

Now you refresh the session by:

. $PROFILE

Now we can use asd to connect to our server without having to enter the password in directly.