_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

sshusage, configuration and tips

back_to_top

ssh [OPTION] REMOTE_HOST [COMMAND]

back_to_top

COMMAND LINE
- options
- x forwarding
TUNNEL
- create
- connect through vpn on ssh tunnel
- commands
CONFIGURATION
- example
- control master
SSH KEYS
TODO
SEE ALSO

back_to_top

-f : fork
-L : local forward
-D : dynamic forward

  • does not work on slackware
    ssh -X
  • trusted, works on debian/slackware
    ssh -Y

back_to_top

Example: This can be used to create a socks proxy for a browser.

ssh -f -D $PORT $SERVER sleep 30000
  • D bindaddres:port / port (assumes localhost)
  • sleep 30000 : keep the connection alive with sleep command

Example: If a SQL Server is only accesible in a different network, a tunnel can be created to access the SQL server through a computer that is accessible from outside that network.

ssh -f -L 127.0.0.1:$PORT:$TARGET_SERVER:$TARGET_PORT $SSH_SERVER_USR@$SSH_SERVER sleep 30000
ssh -f -L 127.0.0.1:1234:SQL_server:1433 user@ssh_server sleep 30000
NOTE: on Microsoft SQL Server Studio use 127.0.0.1,1234

back_to_top

To add configuration options for specific host:

$HOME/.ssh/config
Host hostname
	 [SSH OPTION]

This will always use port 8686 to connect to hostname:

Host hostname
	Port 8686

The user needs to have write permissions in the directory where the socket will be created.

Create a persistent connection when connecting to a remote machine. Eg.:

ssh -f remote sleep 30
Host [HOST]
	ControlMaster auto
	ControlPersist yes
	ControlPath [PATH_TO_CONTROL_SOCKET]/%r@%h:%p

back_to_top

ssh-keygen
Copy the resulting pub contents to the corresponding Host.

back_to_top

back_to_top

ssh(1) , ssh_config(8) , sshd_config(8)

<ssh.oh>

back_to_top

ohazot | about | ohazot.com <admin@ohazot.com>

Created:2025-10-03|Updated:2025-10-06 OpenBSD linux