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".
Command is
ssh -l username server_ip_address
or
ssh username@server_ip_address
If server refuse connection maybe is some different problem. Some firewall settings ...
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?
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.
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.
man ssh
for manual pages.