Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh remote command with wildcard

My goal is to get all IP addresses logging into my web server, by checking access log files:

$ ls -la /var/log/nginx/access.log*
/var/log/nginx/access.log
/var/log/nginx/access.log1
/var/log/nginx/access.log2
...
...

Running the command above locally works:

$ sudo grep loging /var/log/nginx/access.log*

But when I'm trying to run from a remote host

$ ssh remote-server 'sudo grep login /var/log/nginx/access.log*'

It returns:

grep: /var/log/nginx/access.log*: No scuh file or directory

Any idea on what I am doing wrong?

like image 399
jinzoo Avatar asked Oct 14 '25 05:10

jinzoo


1 Answers

One possibility I have found is calling command through bash as an example:

ssh user@host '/bin/bash -c "grep /etc/*"' 

Actually, it is not a ssh issue, the problem is with sudo which takes argument literally, check here.

like image 175
Michal Lis Avatar answered Oct 17 '25 04:10

Michal Lis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!