Remotely Change Password - WeOnlyDo Discussion board

Remotely Change Password (General questions)

by Christopher Brandt, Friday, March 14, 2008, 17:53 (6097 days ago)

We have a requirement to change our account password on a remote SFTP server every 30 days. My gut feeling is that this is actually an SSH operation, not an SFTP operation. But since we're only using the wodSFTP product I'll start here.

Is there anyway through wodSFTP to change a password remotely? If not, how should this be done?

Thanks
Christopher.

Re: Remotely Change Password

by woddrazen, Friday, March 14, 2008, 18:35 (6097 days ago) @ Christopher Brandt

Hi Christopher,


You can change it using our other component wodSSH. Unfortunately this can't be done using wodSFTP.

You are correct in explaining problem. SSH is capable to do that option and SFTP unfortunately isn't.

Hope I helped.


Regards,
Drazen

Re: Remotely Change Password

by Christopher Brandt, Friday, March 14, 2008, 19:02 (6097 days ago) @ woddrazen

Thanks Drazen,

I took a quick look through the SSH.net documentation and it wasn't obvious to me how change a password. Is that something you'd do through the Execute method? I don't have much familiarity with SSH, so I probably need some specific help here (an example).

Christopher

Re: Remotely Change Password

by woddrazen, Friday, March 14, 2008, 19:23 (6097 days ago) @ Christopher Brandt

Christopher,


Here is full example:[code]
Public Class Form1
Dim WithEvents ssh1 As WeOnlyDo.Client.SSH
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ssh1 = New WeOnlyDo.Client.SSH

ssh1.Hostname = your_hostname
ssh1.Blocking = True
ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSH2
ssh1.Login = your_login
ssh1.Password = your_password
ssh1.Connect()

ssh1.WaitFor( regex:[$ #>] $ )
ssh1.DataReady = 0
ssh1.Send( passwd + vbLf)
ssh1.WaitFor( (current) UNIX password: )
ssh1.Send( old_password + vbLf)
ssh1.WaitFor( Enter new UNIX password: )
ssh1.Send( new_password + vbLf)
ssh1.WaitFor( Retype new UNIX password: )
ssh1.Send( new_password + vbLf)
End Sub
End Class
[/code]
When you are connected to server you should use wodSSH.NET WaitFor and Send Method. WaitFor to receive prompt and Send to send command.

Command to change password on UNIX servers is passwd. I cannot be sure that you will receive exact prompt as I did when issuing passwd ((current) UNIX password:, Enter new UNIX password:, Retype new UNIX password:).

Maybe you should first check prompt using for example SSH client Putty and than add it to wodSSH.NET WaitFor Method.

Let us know how it goes.


Regards,
Drazen

Re: Remotely Change Password

by Christopher Brandt, Friday, March 14, 2008, 19:53 (6097 days ago) @ woddrazen

Excellent. Thanks for the help.