How to Make a SSH Connection With PHP

A secure shell application lets you connect to a Linux shell using encryption. PHP offers an SSH connection library you use to make the connection to the server. You must have a username and password to access the SSH server connection. After the connection is made, you can use the SSH commands in the PHP code.

Instructions

    • 1

      Right-click the PHP file you want to use to connect and click "Open With." Click your preferred PHP editor in the list of programs.

    • 2

      Create a connection to the server. The following code connects to the server on port 22:

      $con = ssh2_connect("server.site.com", 22)

      Replace the domain name with the network name for your server.

    • 3

      Specify your username and password. The following code logs in to the server to complete the connection:

      ssh2_auth_password($con, "root", "mypass")

      Replace "root" and "mypass' with your own username and password.

Related Searches:

References

Comments

Related Ads

Featured