Check the remote file whether it exists
ssh -q ubuntu@10.10.10.10 [[ -f /etc/nginx/conf.d/test.conf ]] && echo "true" || echo "false"
Security Researcher, DevOps, SRE
Check the remote file whether it exists
ssh -q ubuntu@10.10.10.10 [[ -f /etc/nginx/conf.d/test.conf ]] && echo "true" || echo "false"
$ ssh -f -N -v -t -L 5433:target_host:5432 user@jump_server
Test the forwarded port using telnet:
$ telnet localhost 5433
or using netcat:
$ nc -vz localhost 5433
This is a quick guide will show you how to open ssh tunnel to ssh into your target server that can only be accessed from jump server. So this is how to do it:
ssh -v -t -L 10443:localhost:20443 <jump_server> ssh -t -L 20443:localhost:443 user@<target_server>
So, here is the example:
ssh -v -t -L 10443:localhost:20443 123.456.1.1 ssh -t -L 20443:localhost:443 user@10.1.1.1
And try it out, see the magic for yourself! after the last command above executed, you will inside your target_server and 10443 port is open from your localhost.
target_server~$
If you want to just have your SSH session running in background and you want to SSH it by yourself, just try this command:
ssh -f -N -v -t -L 10443:localhost:20443 123.456.1.1 ssh -t -L 20443:localhost:443 user@10.1.1.1
if you want to remove the logs (disable verbose mode) when you logging in, just remove the “-v”
SSH to localhost with port 10443, to access your target_server
$ ssh localhost 10443
Magic!
To connect host with specific key
$ ssh user@host -i mykey.pem
Simple tunneling with ssh with port forwarded to connect your service locally. Make sure your local port is available first.
$ ssh -f user@website.com -L 2000:website.com:5432 -N