title: Adding user in ubuntu using PHP
body: <p>I am trying to add user to my Ubuntu Virtual Machine (Microsoft Azure) using PHP from another server.</p>
  
  <p>Here is my code.</p>
  
  <p>PHP Code:</p>
  
  <pre><code>//including phpseclib
  include('Net/SSH2.php');
  
  //Username and Password from form
  $username = $_POST['user'];
  $password = $_POST['pass'];
  
  //connecting to azure vm using ssh
  $ssh = new Net_SSH2('myservername.cloudapp.net:22');
  $ssh-&gt;login('myuserid', 'mypassword') or die("Login failed");
  $ssh-&gt;getServerPublicHostKey();
  $cmd = "sudo useradd -d /home/$username -p $(perl -e'print crypt(\"$password\", \"cu\")') $username";
  $cmdr = $ssh-&gt;exec($cmd);
  </code></pre>
  
  <p>The user is created successfully, but when I login to the server with my newly created username and password using putty it shows "Access Denied"</p>
  
  <p>Kindly help, where am I going wrong?</p>