Introduction#
On the Windows platform, there are many software options available for SSH connections to servers, such as XShell, PuTTY, and Tabby Terminal. However, when I started using Windows Terminal as my main terminal, I didn't want to open other applications to connect via SSH. That's why I wrote this note.
Basic Operations#
Currently, most tutorials found online require editing the settings.json file to achieve the desired configuration. However, with the updates to Windows Terminal, it is now possible to configure it visually. This article will guide you through the process using the GUI.
-
Open Windows Terminal and press
Ctrl+,
to access the settings page. -
On the left side, click on "Add a new profile".
-
Simply click on "Duplicate" - it doesn't matter which one you choose, as you will need to modify it anyway.
-
Rename the profile as desired.
-
If your server is Linux-based (which is likely), you can change the starting directory to
~
or any other directory you prefer. -
You can change the icon to
ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png
which is a Linux penguin icon.
-
The most important setting is the "Command line" setting. Set it to:
ssh -p [port] [username]@[server-ip] # If the port is 22, you can omit -p [port] # Examples: ssh -p 2342 [email protected] ssh [email protected] # If the SSH port is 22
-
Click on "Save" and you're ready to use it.
- However, this method requires entering the password every time you connect, and Windows Terminal does not have a password-saving feature. How can we simplify this process?
Using RSA Keys for Passwordless Login#
-
Make sure your server supports key-based authentication. If you have already set it up, you can skip to the next step.
-
You can refer to this tutorial for instructions. Here are the main steps:
-
Log in to the account you want to use for key-based authentication and execute the following command:
cd ~ & ssh-keygen
-
Press Enter for all prompts. Do not set a passphrase for the key.
cd .ssh cat id_rsa.pub >> authorized_keys chmod 600 authorized_keys chmod 700 ~/.ssh
-
Use FTP to download the
~/.ssh/id_rsa
file (the private key you just generated). I recommend renaming it to a meaningful name and placing it in the%USERPROFILE%/.ssh/
directory, as this is where the automatically generated keys are stored. -
Edit the
/etc/ssh/sshd_config
file and make the following changes (or remove/comment out existing settings):RSAAuthentication yes PubkeyAuthentication yes PermitRootLogin yes # If desired, you can add the following setting to disable password authentication # Make sure to test key-based authentication before enabling this PasswordAuthentication no
-
After testing that key-based authentication works, restart the SSH service:
service sshd restart
- Use
sudo
if necessary.
-
-
Modify the "Command line" value in the Windows Terminal configuration:
ssh -i [private-key-path] -p [port] [username]@[server-ip] # Example: ssh -i "C:/Users/usr/.ssh/id_rsa_server" -p 2342 [email protected]
-
You're all set!
-
If you are following a tutorial or official documentation, make sure to escape the quotes in the
settings.json
file using/
instead of\
, or you can use the escape character. For example:"commandline": "ssh -i \"C:\\Users\\usr\\.ssh\\id_rsa_server\" -p 1145 [email protected]",
Conclusion#
Here is the link to the official Microsoft documentation on Windows Terminal SSH.
With the current version of Windows Terminal, most operations can be done visually, so there is no need to modify the settings.json
file unless you have specific requirements.