How to use the command 'tailscale ssh' (with examples)
Tailscale is a tool that provides secure networking across multiple devices and networks. The ’tailscale ssh’ command allows users to SSH into a Tailscale machine from their local machine. This article will illustrate each of the following use cases of the command.
Use case 1: Advertise/Disable SSH on the host
Code:
sudo tailscale up --ssh=true|false
Motivation:
Enabling or disabling SSH on the host is useful when you want to control remote access to the Tailscale machine. By enabling SSH, you can remotely connect to the machine using SSH. On the other hand, disabling SSH ensures that no remote access is allowed.
Explanation:
sudo
: Executes the following command with administrative privileges.tailscale up
: Starts Tailscale on the host.--ssh=true|false
: Sets whether SSH should be enabled or disabled. Use ’true’ to enable and ‘false’ to disable SSH.
Example output:
Enabling SSH:
sudo tailscale up --ssh=true
Starting Tailscale...
SSH advertisement enabled.
Disabling SSH:
sudo tailscale up --ssh=false
Starting Tailscale...
SSH advertisement disabled.
Use case 2: SSH to a specific host with Tailscale-SSH enabled
Code:
tailscale ssh username@host
Motivation:
When multiple hosts have Tailscale-SSH enabled, you can use this command to SSH directly into a specific host. This is useful for managing and accessing Tailscale-SSH enabled machines without having to go through a jump host or specifying port numbers.
Explanation:
tailscale
: The command to interact with Tailscale.ssh
: Subcommand to SSH into a Tailscale-SSH enabled host.username@host
: The username and hostname or IP address of the host you want to SSH into.
Example output:
tailscale ssh john@example.com
Connecting to john@example.com...
SSH session established.
Conclusion:
The ’tailscale ssh’ command is a useful tool to enable or disable SSH on Tailscale machines and to SSH directly into specific hosts. It provides a convenient way to manage and access Tailscale-SSH enabled machines securely.