Execute one line command using ssh in linux/Unix

Execute one line command using ssh in linux/Unix

As we all know ssh (secure shell) is used to login to remote linux / Unix machine. SSH also has special privilege to execute one line command in remote machine. We can use this option in scripting for collecting logs.

Execute one line command using ssh in linux/Unix
Syntax:

ssh username@ipaddress ‘command’
ssh username@domainname ‘command’
ssh username@domainname ‘command1 | command2′

Lets see how it works.

ssh tts@192.168.1.9 ‘df -Th’
ssh tts@192.168.1.9 ‘ls -l /etc/httpd’
ssh tts@192.168.1.9 ‘grep -i tts /etc/passwd’

Execute one line command using ssh in linux/Unix

Execute one line command using ssh in linux/Unix




Leave a Reply

Your email address will not be published. Required fields are marked *