Jump to content


P4API.NET connects to Perforce server via rsh protocol


  • Please log in to reply
4 replies to this topic

#1 laurent_tr

laurent_tr

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 June 2019 - 06:49 AM

Hello,

One of our clients has configured their Perforce server to be connected only via rsh protocol/
In general, Perforce users will have to generate a pair of private-public keys, the public key is stored in an internal SSHD server, and the private key is loaded in a Putty agent (we all use Windows workstation).
The P4PORT is then set to something like this: "rsh:plink.exe -ssh -batch -a -x -l p4user some.server.com ...."
In such a way, they no longer need to authenticate with "p4 login", instead they issue the command that they want, "p4 info" for example, their private key is verified with the public key and if it's matched, the p4 command is transferred to the Perforce server at some.server.com.

I have tried to find some documentation about the support of this rsh protocol on P4 documentation but the only one I have found, that's come from Perforce is this: https://www.perforce...ew/tsld020.htm.
What I want to know is how to make this works with the P4API.NET. In particular, how will I create the connection with the API?
Following is the snippet of code that I use to connect to our Perforce testing environment, which does not have the same authentication configuration as the client in question.

public bool Connect()
{
// define the server, repository and connection
_server = new Server(new ServerAddress(_cntr._serverUri));
_repository = new Repository( _server);
_connection = _repository.Connection;
// use the connection variables for this connection
_connection.UserName = _cntr._user;
_connection.Client = new Client();
var options = new Options();
options["ProgramName"] = ApplicationName;
options["ProgramVersion"] = ApiVersion;
// connect to the server
try
{
	 if (!_connection.Connect(options))
	 {
		 Sys.LogError($"{nameof(PerforceClient)}.Connect could not connect to Perforce server at {_cntr._serverUri}, with the user {_cntr._user}.");
		 return false;
	 }
	 var credential = _connection.Login(_cntr._pwd.Password);
	 // Save the ticket expiration time, remove 5 min to be more proactive on the expiration time
	 _ticketExpirationTime = Dat.MinSub(credential.Expires, 5);
	 return true;
}
catch (Exception e)
{
	 Sys.LogError($"{nameof(PerforceClient)}.Connect could not connect to Perforce server at {_cntr._serverUri}, with the user {_cntr._user}.", e);
	 return false;
}
}

Thank you very much for your help.

#2 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 25 June 2019 - 02:43 PM

Hello,

The link that you reference is showing me a page not found error. I have no familiarity with connecting via rsh. For this question, you are probably better off emailing support@perforce.com.

Have you tried connecting under the client's auth configuration? If setting P4PORT to the "rsh:..." you mention works for the P4 command line client, it may just work with P4API.NET by setting the same for _serverUri.

#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1077 posts

Posted 25 June 2019 - 05:31 PM

FWIW the rsh: syntax is implemented in the C++ API, so to the extent that P4API.NET wraps the C++ library it probably "just works":

https://swarm.worksh...etportparser.cc

#4 laurent_tr

laurent_tr

    Member

  • Members
  • PipPip
  • 10 posts

Posted 26 June 2019 - 09:15 AM

Hello,

Thank you for your reply, @p4bill and @Sambwise.

The reference link is here: https://www.perforce...new/tsld020.htm
It does not work because the link has included the "." character at the end of the sentence.

@p4bill, would it be ok if I ask you to file a doc ticket to update the reference of p4port to have example of "rsh:" protocol, especially, it differs from other protocols in the way that it can execute a bash command.

Thanks.

#5 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 27 June 2019 - 02:31 PM

@laurent_tr Sure thing. I'll log that doc improvement request now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users