Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to connect to my remote machine through SSH command line, but I don't know what are the appropriate terminal commands.

I always get an error "connection refused".

share|improve this question
Excelent how-to on Ubuntu official help. Also type man ssh for manual pages. – hmayag Apr 30 '14 at 6:45
What commands are you using that give the error? – terdon Apr 30 '14 at 11:44

Command is

ssh -l username server_ip_address


ssh username@server_ip_address

If server refuse connection maybe is some different problem. Some firewall settings ...

share|improve this answer
I agree on the commands, but can you expand on the possible problems? Firewall, wrong pass, certificates, etc. – don.joey Apr 30 '14 at 6:22
First try with nmap server_ip_address. Is server is up with ssh service ready to accept connection you will see PORT STATE SERVICE 22/tcp open ssh. If port is open server is ready. Do you have root privilege for server? – 2707974 Apr 30 '14 at 6:30

First of all you must be sure that the ssh server you want to connect is running. To do this, try typing:

telnet server_ip 22 

where 22 is the default port of the ssh protocol. If the port is different, you must change it. If the server replies to you, you can connect this way:

ssh <username>@server_ip -p 22 

is the user who has permission to access the server via ssh. The -p 22 argument can omit it if the port is the default, or if you use a different port you have to use it.

share|improve this answer

If I recall correctly, the ssh server sshd is not installed in Ubuntu by default.

sudo apt-get install openssh-server openssh-client

run on both machines will get ssh and sshd installed.

WARNING: sshd is not installed by default for good reason, it has the potential to open your system to any black-hat hacker or bot on the internet especially if you have weak passwords or firewalls. You should understand the security hole that you'll open before you open it.

share|improve this answer
you don't need openssh-server on the client machine, and openssh-client is not necessary on the server. Just make sure you have openssh-server installed and running on the server and openssh-client installed on the client. – Calimo Apr 30 '14 at 13:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.