Ssh: remote execute (en)
Jump to navigation
Jump to search
example
ssh user1@server1 command1 ssh user1@server1 'command2' ssh user1@server1 'command1 | command2'
ssh user1@server1 date ssh user1@server1 'df -H' ssh root@nas01 uname -mrs ssh root@nas01 lsb_release -a
ssh -t user@server "time sudo /home/user/script.sh"
Where:
-t - provides terminal access if the script requests a password sudo - to allow execution as superuser
Copy id_dsa.pub & id_rsa.pub
Ensure id_dsa.pub or id_rsa.pub is copied to the remote server,
ssh -l remoteuser remoteserver.com 'mkdir .ssh' ssh -l remoteuser remoteserver.com 'touch ~/.ssh/authorized_keys' cat ~/.ssh/id_dsa.pub | ssh -l remoteuser remoteserver.com 'cat >> ~/.ssh/authorized_keys'