SSH into a remote server (if available) using a key file and check the logged-in username. (Use whoami)

1 min read
SSH into the Remote Server Using a Key File
Use the following command to connect to the remote server:
bashCopyEditssh -i /path/to/private_key username@remote_server_ip
-i /path/to/private_key
→ Specifies the SSH private key fileusername@remote_server_ip
→ Replace with your actual username and server IP/domain
Step 2: Verify the Logged-in Username
Once logged in, run:
bashCopyEditwhoami
Expected Output:
nginxCopyEditusername
This confirms that you are logged in as "username" on the remote server.
Step 3: (Optional) Check the Hostname
To verify the server name, run:
bashCopyEdithostname
Example Output:
pgsqlCopyEditremote-server
0
Subscribe to my newsletter
Read articles from Ravi Vishwakarma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
