In this article, we will learn how to add the terminal as default software for direct access to computers with an SSH connection within VaultOne.
Prerequisites
Before you begin, you need:
A Linux system
Access to the terminal
A computer/server configured for SSH connection in VaultOne
Installation
First step: Add the script handler
In the user's home directory, create a directory named vaultone-handler:
mkdir ~/vaultone-handler
Navigate into the folder and create a file named vaultone-ssh- handler.sh:
touch ssh-handler.sh
Change the file permissions to make it executable:
chmod u+x ssh-handler.sh
Open the file with your preferred editor add the following linas then save:
#!/bin/bash
open_terminal() {
local term_cmd=""
# Detecta o terminal disponível e define o comando correspondente
if command -v gnome-terminal &> /dev/null; then
term_cmd="gnome-terminal -- $1"
elif command -v konsole &> /dev/null; then
term_cmd="konsole -e $1"
elif command -v xfce4-terminal &> /dev/null; then
term_cmd="xfce4-terminal -- $1"
elif command -v xterm &> /dev/null; then
term_cmd="xterm -e $1"
elif command -v urxvt &> /dev/null; then
term_cmd="urxvt -e $1"
elif command -v lxterminal &> /dev/null; then
term_cmd="lxterminal -e $1"
elif command -v mate-terminal &> /dev/null; then
term_cmd="mate-terminal -- $1"
elif command -v terminology &> /dev/null; then
term_cmd="terminology -e $1"
else
echo "No compatible terminals found. Please install a terminal"
exit 1
fi
eval "$term_cmd" &
}
main() {
if [[ "$1" != "ssh://"* ]]; then
echo "Is not valid SSH URL"
exit 1
fi
local url=${1#ssh://}
local user_pass=${url%%@*}
local host_port=${url%%*@}
local host=${host_port%%:*}
local port=${host_port##*:}
[ "$port" == "$host_port" ] && port=''
local cmd="$host"
[ -n "$user" ] && cmd="$user@$cmd"
[ -n "$port" ] && cmd="$cmd -p $port"
cmd="ssh $cmd -o StrictHostKeyChecking=no -o UserKnownHosts
open_terminal "$cmd"
}
main "$1"
Second step: Add SSH Protocol Handler configuration
Navigate to ~/.local/share/applications/ and create a file named SSH-Handler.desktop:
cd ~/.local/share/applications/
touch SSH-Handler.desktop
Change the file permissions to make it executable:
chmod u+x SSH-Handler.desktop
Open the file with your preferred editor and add the following linas. Before saving, replace your-user with your username:
[Desktop Entry]
Type=Application
Name=SSH Handler
Exec=/home/your-user/vaultone-handler/ssh-handler.sh %u
Icon=utilities-terminal
StartupNotify=false
MimeType=x-scheme-handler/ssh
Third step: Register the Protocol Handler with the system
Allowing the system to recognize ssh:// links, register the script as a Protocol Handler for SSH:
xdg-mime default SSH-Handler.desktop x-scheme-handler/ssh
Fourth step: Connect to a computer via SSH using Direct Access
With everything set up, proceed to VaultOne and connect to a computer via SSH:
Select your computer and click Connect:
Then click on Direct Access:
Finally, click Open:
A terminal should open connecting your computer to the Bastion of your connector, already configured to connect to the selected computer. Follow the bastion authentication steps to complete the connection to the computer.
Was this article helpful? Did you still have doubts? You can get in touch with us! [email protected]