How to execute SSH commands on a remote server
SSH (Secure Shell) lets you connect to a remote server and run commands as if you were sitting at that machine. In particular, you can manage a VPS, dedicated server, or hosting account from your local computer. Furthermore, you can use password or SSH key authentication, and run commands interactively or in a single one-off call. All traffic is encrypted, making SSH the standard way to administer Linux servers remotely.
Connect with password
To connect to a remote server, you need the hostname or IP, a username, and a password. Run:
ssh user@server.hostname.comReplace user with your username and server.hostname.com with the server address (or IP). When prompted, enter the password. Once connected, you can run any command on the remote server. Type exit or press Ctrl+D to disconnect.
Connect with SSH key (more secure)
Password logins can be targeted by brute-force attacks. SSH keys are more secure. Generate a key pair, add the public key to the server, and connect with:
ssh -i /path/to/ssh_key user@server.hostname.comReplace /path/to/ssh_key with the path to your private key (e.g. ~/.ssh/id_rsa). If the key has a passphrase, you will be prompted for it. You can disable password login on the server and use only keys for stronger security.
Run a single command without interactive shell
To run one command on the remote server and then disconnect:
ssh user@server.hostname.com "ls -la"Put the command in quotes. Useful for scripts, backups, or quick checks: ssh user@host "df -h", ssh user@host "tail -20 /var/log/error.log".
Commands and options
Once connected, you run the same Linux commands you would locally. Commands accept flags and options. For example, ls lists files; ls -la shows a detailed list including hidden files. To learn more about each command:
man lsOr:
ls --helpSee our guides on SSH commands such as ls, cd, and cat for common tasks.
Common use cases
Typical uses for remote SSH:
- Managing a VPS or dedicated server from your laptop
- Running deployment scripts or backups on a remote host
- Checking logs, disk space, or processes on a remote machine
- Editing config files or restarting services on a hosting account
Need more help?
Explore more SSH and hosting guides in our knowledgebase. JetHost web hosting includes SSH access on plans that support it. For VPS and dedicated servers, you get full root access for remote management.


