title: Sudo SU in Bash script without asking user for password
body: <p>My user is in root group. I canot ssh to server as root because is says <code>Permission denied, please try again.</code> What I usualy do is I ssh as my user and once I'm logged in i type <code>sudo su</code> and I proivde my user's password to become root. </p>
  
  <p>I want to automate part of my job so I want to write a bash script which would ssh as my user, switch to root and then call set of commands.</p>
  
  <p>So far I came with following script but I am unable to switch to root user without asking user for password:</p>
  
  <pre><code>while read p; do
     p=$(echo $p|tr -d '\r')
     sshpass -p "myPasswd" ssh  -T -o StrictHostKeyChecking=no myUser@remoteServer &lt;&lt; EOT
     cd /var/log/jboss/   #here I am getting 'permission denied' message as only root has access
     exit
  EOT
  done &lt; $nodes
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>sshpass -p "myPasswd" ssh  -tt -o StrictHostKeyChecking=no myUser@remoteServer 'cd /var/log/jboss/'
  </code></pre>
  
  <p>but I got the same <code>permission denied</code> error message</p>