Linux remote login

How do i login to a remote linux machine from VB?

Page 1 of 1

5 Replies - 3179 Views - Last Post: 21 April 2009 - 11:30 AM Rate Topic: -----

#1 ALSFelix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-January 09

Linux remote login

Posted 26 January 2009 - 12:47 PM

Hi

I need to login to a remote linux machine and change my users password from a VB.NET 2008 program (from windows lol) ...
Is this possible?

How can i do this?


Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Linux remote login

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Linux remote login

Posted 26 January 2009 - 08:36 PM

I am really not sure if it is possible, unless you are creating an interface that will connect both machines and which supports a wide range of linux functions and commands (as you want to perform some administrative operations on a remote machine).

And this is the forum for VB (version 6 and earlier questions). VB2008 refers to the VB.NET forum:

http://www.dreaminco...showforum67.htm

Dream.In.Code forum rules state that you should show some effort in solving your problem. Please, post the code you've been working so far. Post the code between code tags: :code:

Thank you!
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,071
  • Joined: 10-May 07

Re: Linux remote login

Posted 26 January 2009 - 09:04 PM

View PostALSFelix, on 26 Jan, 2009 - 01:47 PM, said:

I need to login to a remote linux machine and change my users password

Could you clarify as to why you need to do this?

I wouldn't normally poke so much, but when someone is working on automated password utilities, it's generally malicious in nature.
Was This Post Helpful? 0
  • +
  • -

#4 ALSFelix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-January 09

Re: Linux remote login

Posted 08 February 2009 - 07:18 AM

View Postno2pencil, on 26 Jan, 2009 - 08:04 PM, said:

View PostALSFelix, on 26 Jan, 2009 - 01:47 PM, said:

I need to login to a remote linux machine and change my users password

Could you clarify as to why you need to do this?

I wouldn't normally poke so much, but when someone is working on automated password utilities, it's generally malicious in nature.



Hi.

It's not malicious.

I'm an IBM iSeries administrator and every 45 or 90 days i have to change my users passwords on 25 to 40 iSeries Partitions (AS/400) and respective service tools. I've made a small app (VB.NET 2008) to do this automatically through operating system APIs and keeping the same or diferent password everywhere (on all systems).
All i have to do is provide the app with the ip, user and password of the systems, and the new password.
The app will logon with my user, change my password and return an error code (If it is 0 password change is OK).
The systems are setup to send an email to any user that changes his password.

IBM Client Access Provides a DLL called CWBX.DLL that can give access to AS/400 or iSeries APIs. That's what i'm using for the systems and Service Tools.

However my systems are managed by an HMC (Hardware Mangement Console) and the HMC O.S. is linux (IBM). So i need to change it's password too. I'm not experienced with linux. What i need is to login remotely (from my PC using windows XP) and change MY password. That's all.

Like i said: I'm part of a team that manages 76 AS/400 or iSeries partitions and 27 HMCs.
The objective of this is not to waste an entire morning or afternoon changing passwords and, at the same time keep track of my password and the changes i've made to them. The tools you can find on the market (Ex.: One Time Password) can't manage AS/400 or iSeries passwords. So i'm trying to make my own tool.

If i'm posting in the wrong forum i'm sorry.
I can't post any code because i don't have any for Linux yet.
I don't even know how or if it is possible to login remotlely (SSH) to linux form VB.NET or any other VB.
I can post what i have for the iSeries systems.

Login Function:

	Function AS400SignOn(ByVal FunctionSysName As String, ByVal FunctionIPAddress As String, _
						 ByVal FunctionUserID As String, ByVal FunctionPassWord As String) As Boolean
		On Error GoTo Signonerror

		i5SysSignOn = CreateObject("cwbx.AS400System")

		i5SysSignOn.Define(FunctionSysName)
		i5SysSignOn.IPAddress = FunctionIPAddress
		i5SysSignOn.UserID = Trim(FunctionUserID)
		i5SysSignOn.Password = Trim(FunctionPassWord)
		i5SysSignOn.PromptMode = cwbx.cwbcoPromptModeEnum.cwbcoPromptNever
		i5SysSignOn.Signon()

		AS400SignOn = True
		Exit Function
Signonerror:
		Debug.WriteLine(FunctionSysName)
		Debug.WriteLine("Error Number ..........................: " & Err.Number & vbCr & _
						"Error Description .....................: " & Err.Description & vbCr & _
						"Error Source ..........................: " & Err.Source & vbCr & _
						"iSeries Access for Windows Return Code : " & i5SysSignOn.Errors.ReturnCode)
		AS400SignOn = False
	End Function



Function to retrieve the system status:
	Function RtvSysSts(ByRef ReturnSystemValues As ReturnSystemStatus) As Boolean
		On Error GoTo Functionerror

		Dim Pgm As Object = CreateObject("cwbx.Program")
		Dim parms As Object = CreateObject("cwbx.ProgramParameters")

		Dim SysStsInfo As Object = CreateObject("cwbx.Structure")
		Dim StrCvtr As Object = CreateObject("cwbx.StringConverter")
		Dim LongCvtr As Object = CreateObject("cwbx.LongConverter")

		' Retrieve the default system and use it to initialize the AS400System object
		' Set the System property of the Program object
		Pgm.System = i5SysSignOn
		' Set the LibraryName property of the Program object
		Pgm.LibraryName = "QSYS"
		' Set the ProgramName property of the Program object
		Pgm.ProgramName = "QWCRSSTS"
		'Define parameters and set all input parameter values
		parms.Append("receiver", cwbx.cwbrcParameterTypeEnum.cwbrcOutput, 132)
		parms.Append("receiver size", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("receiver size") = LongCvtr.ToBytes(132)
		parms.Append("format", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("format") = StrCvtr.ToBytes("SSTS0200")
		parms.Append("reset", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("reset") = StrCvtr.ToBytes("*NO	   ")
		parms.Append("error code", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("error code") = LongCvtr.ToBytes(0)
		' Call the AS/400 system API to retrieve the system status
		Pgm.Call(parms)
		' Store the system ststus information in a Structure object so we can retrieve individual field values
		SysStsInfo.Bytes = parms("receiver").Value
		' Define the layout of the returned message information
		SysStsInfo.Fields.Append("bytesAvailable", 4)
		SysStsInfo.Fields.Append("bytesReturned", 4)
		SysStsInfo.Fields.Append("CurrentDateAndTime", 8) ' System Time Stamp... Must convert...
		SysStsInfo.Fields.Append("SystemName", 8)
		SysStsInfo.Fields.Append("ElapsedTime", 6)
		SysStsInfo.Fields.Append("RestrictedStateFlag", 1)
		SysStsInfo.Fields.Append("Reserved", 1)
		SysStsInfo.Fields.Append("CPUpct", 4)
		SysStsInfo.Fields.Append("JobsinSystem", 4)
		SysStsInfo.Fields.Append("permaddress", 4)
		SysStsInfo.Fields.Append("tempaddress", 4)
		SysStsInfo.Fields.Append("SysASP", 4)
		SysStsInfo.Fields.Append("SysASPused", 4)
		SysStsInfo.Fields.Append("TotalAuxiliary", 4)
		SysStsInfo.Fields.Append("CurrentUnprotectedStorageUsed", 4)
		SysStsInfo.Fields.Append("MaximumUnprotectedStorageUsed", 4)
		SysStsInfo.Fields.Append("PercentDBCapability", 4)
		SysStsInfo.Fields.Append("MainStorageSize", 4)
		SysStsInfo.Fields.Append("NumberOfPartitions", 4)
		SysStsInfo.Fields.Append("PartitionIdentifier", 4)
		SysStsInfo.Fields.Append("Reserved", 4)
		SysStsInfo.Fields.Append("CurrentProcessingCapacity", 4)
		SysStsInfo.Fields.Append("ProcessorSharingAttribute", 1)
		SysStsInfo.Fields.Append("Reserved", 3)
		SysStsInfo.Fields.Append("NumberOfProcessors", 4)
		SysStsInfo.Fields.Append("ActiveJobsInSystem", 4)

		'Parse the retrieved syssts description
		ReturnSystemValues.RtnSysNam = StrCvtr.FromBytes(SysStsInfo("SystemName").Value)
		ReturnSystemValues.RtnDatTim = StrCvtr.FromBytes(SysStsInfo("CurrentDateAndTime").Value) ' System Time Stamp... Must convert...
		ReturnSystemValues.RtnJobsIn = Str(LongCvtr.FromBytes(SysStsInfo("JobsinSystem").Value))
		ReturnSystemValues.RtnCPUNum = Str(LongCvtr.FromBytes(SysStsInfo("NumberOfProcessors").Value))
		ReturnSystemValues.RtnCpuPct = Str(LongCvtr.FromBytes(SysStsInfo("CPUpct").Value) / 10)
		ReturnSystemValues.RtnSysAsp = Str(LongCvtr.FromBytes(SysStsInfo("SysASP").Value) / 1000)
		ReturnSystemValues.RtnAspUsd = Str(LongCvtr.FromBytes(SysStsInfo("SysASPused").Value) / 10000)
		ReturnSystemValues.RtnCurCap = Str(LongCvtr.FromBytes(SysStsInfo("CurrentProcessingCapacity").Value) / 100)
		ReturnSystemValues.RtnShrAtr = StrCvtr.FromBytes(SysStsInfo("ProcessorSharingAttribute").Value)
		ReturnSystemValues.RtnActJob = Str(LongCvtr.FromBytes(SysStsInfo("ActiveJobsInSystem").Value))

		If Trim(ReturnSystemValues.RtnShrAtr) = "0" Then
			ReturnSystemValues.RtnShrSts = " Dedicated"
		ElseIf Trim(ReturnSystemValues.RtnShrAtr) = "1" Then
			ReturnSystemValues.RtnShrSts = " Shared (Capped)"
		ElseIf Trim(ReturnSystemValues.RtnShrAtr) = "2" Then
			ReturnSystemValues.RtnShrSts = " Shared (UnCapped)"
		End If

		RtvSysSts = True
		Exit Function
Functionerror:
		ReturnSystemValues.RtnSysNam = "<ERROR>"
		ReturnSystemValues.RtnDatTim = "<ERROR>"
		ReturnSystemValues.RtnJobsIn = "<ERROR>"
		ReturnSystemValues.RtnCPUNum = "<ERROR>"
		ReturnSystemValues.RtnCpuPct = "<ERROR>"
		ReturnSystemValues.RtnSysAsp = "<ERROR>"
		ReturnSystemValues.RtnAspUsd = "<ERROR>"
		ReturnSystemValues.RtnCurCap = "<ERROR>"
		ReturnSystemValues.RtnShrAtr = "<ERROR>"
		ReturnSystemValues.RtnActJob = "<ERROR>"

		RtvSysSts = False
	End Function


Thanks.

This post has been edited by ALSFelix: 08 February 2009 - 08:00 AM

Was This Post Helpful? 0
  • +
  • -

#5 amulon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-April 09

Re: Linux remote login

Posted 21 April 2009 - 11:19 AM

View PostALSFelix, on 8 Feb, 2009 - 06:18 AM, said:

View Postno2pencil, on 26 Jan, 2009 - 08:04 PM, said:

View PostALSFelix, on 26 Jan, 2009 - 01:47 PM, said:

I need to login to a remote linux machine and change my users password

Could you clarify as to why you need to do this?

I wouldn't normally poke so much, but when someone is working on automated password utilities, it's generally malicious in nature.



Hi.

It's not malicious.

I'm an IBM iSeries administrator and every 45 or 90 days i have to change my users passwords on 25 to 40 iSeries Partitions (AS/400) and respective service tools. I've made a small app (VB.NET 2008) to do this automatically through operating system APIs and keeping the same or diferent password everywhere (on all systems).
All i have to do is provide the app with the ip, user and password of the systems, and the new password.
The app will logon with my user, change my password and return an error code (If it is 0 password change is OK).
The systems are setup to send an email to any user that changes his password.

IBM Client Access Provides a DLL called CWBX.DLL that can give access to AS/400 or iSeries APIs. That's what i'm using for the systems and Service Tools.

However my systems are managed by an HMC (Hardware Mangement Console) and the HMC O.S. is linux (IBM). So i need to change it's password too. I'm not experienced with linux. What i need is to login remotely (from my PC using windows XP) and change MY password. That's all.

Like i said: I'm part of a team that manages 76 AS/400 or iSeries partitions and 27 HMCs.
The objective of this is not to waste an entire morning or afternoon changing passwords and, at the same time keep track of my password and the changes i've made to them. The tools you can find on the market (Ex.: One Time Password) can't manage AS/400 or iSeries passwords. So i'm trying to make my own tool.

If i'm posting in the wrong forum i'm sorry.
I can't post any code because i don't have any for Linux yet.
I don't even know how or if it is possible to login remotlely (SSH) to linux form VB.NET or any other VB.
I can post what i have for the iSeries systems.

Login Function:

	Function AS400SignOn(ByVal FunctionSysName As String, ByVal FunctionIPAddress As String, _
						 ByVal FunctionUserID As String, ByVal FunctionPassWord As String) As Boolean
		On Error GoTo Signonerror

		i5SysSignOn = CreateObject("cwbx.AS400System")

		i5SysSignOn.Define(FunctionSysName)
		i5SysSignOn.IPAddress = FunctionIPAddress
		i5SysSignOn.UserID = Trim(FunctionUserID)
		i5SysSignOn.Password = Trim(FunctionPassWord)
		i5SysSignOn.PromptMode = cwbx.cwbcoPromptModeEnum.cwbcoPromptNever
		i5SysSignOn.Signon()

		AS400SignOn = True
		Exit Function
Signonerror:
		Debug.WriteLine(FunctionSysName)
		Debug.WriteLine("Error Number ..........................: " & Err.Number & vbCr & _
						"Error Description .....................: " & Err.Description & vbCr & _
						"Error Source ..........................: " & Err.Source & vbCr & _
						"iSeries Access for Windows Return Code : " & i5SysSignOn.Errors.ReturnCode)
		AS400SignOn = False
	End Function



Function to retrieve the system status:
	Function RtvSysSts(ByRef ReturnSystemValues As ReturnSystemStatus) As Boolean
		On Error GoTo Functionerror

		Dim Pgm As Object = CreateObject("cwbx.Program")
		Dim parms As Object = CreateObject("cwbx.ProgramParameters")

		Dim SysStsInfo As Object = CreateObject("cwbx.Structure")
		Dim StrCvtr As Object = CreateObject("cwbx.StringConverter")
		Dim LongCvtr As Object = CreateObject("cwbx.LongConverter")

		' Retrieve the default system and use it to initialize the AS400System object
		' Set the System property of the Program object
		Pgm.System = i5SysSignOn
		' Set the LibraryName property of the Program object
		Pgm.LibraryName = "QSYS"
		' Set the ProgramName property of the Program object
		Pgm.ProgramName = "QWCRSSTS"
		'Define parameters and set all input parameter values
		parms.Append("receiver", cwbx.cwbrcParameterTypeEnum.cwbrcOutput, 132)
		parms.Append("receiver size", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("receiver size") = LongCvtr.ToBytes(132)
		parms.Append("format", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("format") = StrCvtr.ToBytes("SSTS0200")
		parms.Append("reset", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("reset") = StrCvtr.ToBytes("*NO	   ")
		parms.Append("error code", cwbx.cwbrcParameterTypeEnum.cwbrcInput)
		parms("error code") = LongCvtr.ToBytes(0)
		' Call the AS/400 system API to retrieve the system status
		Pgm.Call(parms)
		' Store the system ststus information in a Structure object so we can retrieve individual field values
		SysStsInfo.Bytes = parms("receiver").Value
		' Define the layout of the returned message information
		SysStsInfo.Fields.Append("bytesAvailable", 4)
		SysStsInfo.Fields.Append("bytesReturned", 4)
		SysStsInfo.Fields.Append("CurrentDateAndTime", 8) ' System Time Stamp... Must convert...
		SysStsInfo.Fields.Append("SystemName", 8)
		SysStsInfo.Fields.Append("ElapsedTime", 6)
		SysStsInfo.Fields.Append("RestrictedStateFlag", 1)
		SysStsInfo.Fields.Append("Reserved", 1)
		SysStsInfo.Fields.Append("CPUpct", 4)
		SysStsInfo.Fields.Append("JobsinSystem", 4)
		SysStsInfo.Fields.Append("permaddress", 4)
		SysStsInfo.Fields.Append("tempaddress", 4)
		SysStsInfo.Fields.Append("SysASP", 4)
		SysStsInfo.Fields.Append("SysASPused", 4)
		SysStsInfo.Fields.Append("TotalAuxiliary", 4)
		SysStsInfo.Fields.Append("CurrentUnprotectedStorageUsed", 4)
		SysStsInfo.Fields.Append("MaximumUnprotectedStorageUsed", 4)
		SysStsInfo.Fields.Append("PercentDBCapability", 4)
		SysStsInfo.Fields.Append("MainStorageSize", 4)
		SysStsInfo.Fields.Append("NumberOfPartitions", 4)
		SysStsInfo.Fields.Append("PartitionIdentifier", 4)
		SysStsInfo.Fields.Append("Reserved", 4)
		SysStsInfo.Fields.Append("CurrentProcessingCapacity", 4)
		SysStsInfo.Fields.Append("ProcessorSharingAttribute", 1)
		SysStsInfo.Fields.Append("Reserved", 3)
		SysStsInfo.Fields.Append("NumberOfProcessors", 4)
		SysStsInfo.Fields.Append("ActiveJobsInSystem", 4)

		'Parse the retrieved syssts description
		ReturnSystemValues.RtnSysNam = StrCvtr.FromBytes(SysStsInfo("SystemName").Value)
		ReturnSystemValues.RtnDatTim = StrCvtr.FromBytes(SysStsInfo("CurrentDateAndTime").Value) ' System Time Stamp... Must convert...
		ReturnSystemValues.RtnJobsIn = Str(LongCvtr.FromBytes(SysStsInfo("JobsinSystem").Value))
		ReturnSystemValues.RtnCPUNum = Str(LongCvtr.FromBytes(SysStsInfo("NumberOfProcessors").Value))
		ReturnSystemValues.RtnCpuPct = Str(LongCvtr.FromBytes(SysStsInfo("CPUpct").Value) / 10)
		ReturnSystemValues.RtnSysAsp = Str(LongCvtr.FromBytes(SysStsInfo("SysASP").Value) / 1000)
		ReturnSystemValues.RtnAspUsd = Str(LongCvtr.FromBytes(SysStsInfo("SysASPused").Value) / 10000)
		ReturnSystemValues.RtnCurCap = Str(LongCvtr.FromBytes(SysStsInfo("CurrentProcessingCapacity").Value) / 100)
		ReturnSystemValues.RtnShrAtr = StrCvtr.FromBytes(SysStsInfo("ProcessorSharingAttribute").Value)
		ReturnSystemValues.RtnActJob = Str(LongCvtr.FromBytes(SysStsInfo("ActiveJobsInSystem").Value))

		If Trim(ReturnSystemValues.RtnShrAtr) = "0" Then
			ReturnSystemValues.RtnShrSts = " Dedicated"
		ElseIf Trim(ReturnSystemValues.RtnShrAtr) = "1" Then
			ReturnSystemValues.RtnShrSts = " Shared (Capped)"
		ElseIf Trim(ReturnSystemValues.RtnShrAtr) = "2" Then
			ReturnSystemValues.RtnShrSts = " Shared (UnCapped)"
		End If

		RtvSysSts = True
		Exit Function
Functionerror:
		ReturnSystemValues.RtnSysNam = "<ERROR>"
		ReturnSystemValues.RtnDatTim = "<ERROR>"
		ReturnSystemValues.RtnJobsIn = "<ERROR>"
		ReturnSystemValues.RtnCPUNum = "<ERROR>"
		ReturnSystemValues.RtnCpuPct = "<ERROR>"
		ReturnSystemValues.RtnSysAsp = "<ERROR>"
		ReturnSystemValues.RtnAspUsd = "<ERROR>"
		ReturnSystemValues.RtnCurCap = "<ERROR>"
		ReturnSystemValues.RtnShrAtr = "<ERROR>"
		ReturnSystemValues.RtnActJob = "<ERROR>"

		RtvSysSts = False
	End Function


Thanks.

I use a freeware program that let me tunnel into the HMC. Then I issue the chhmcusr -u command to change the password for the user. A list of all the command can be found @ http://publib.boulde...ommandslist.htm
Was This Post Helpful? 0
  • +
  • -

#6 amulon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-April 09

Re: Linux remote login

Posted 21 April 2009 - 11:30 AM

I do my rack configs and System infromation that I can get thought VB scripts to the HMC. I'm not an expert by any means.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1