Questions tagged [ssh]

SSH, or "Secure Shell", is a networking protocol for securely connecting to a remote computer over an unsecure network. SSH is also the name of the default command-line SSH client. This tag is for questions involving using and troubleshooting SSH connections, as well as setting up and configuring SSH for applications which use the SSH protocol. This tag should be used with other tags to better identify the environment of the problem.

Ubuntu installs an SSH client (openssh-client) by default. If you want to be able to log in remotely into your machine, you need the server package (openssh-server). There are SSH clients for Windows as well, such as PuTTY.

Troubleshooting

If public key authentication doesn't work: make sure that on the server side, your home directory (~), the ~/.ssh directory, and the ~/.ssh/authorized_keys file, are all writable only by their owner. In particular, none of them must be writable by the group (even if the user is alone in the group). chmod 755 or chmod 700 is ok, chmod 770 is not.

What to check when something is wrong:

  • Run ssh -vvv to see a lot of debugging output. If you post a question asking why you can't connect with ssh, include this output (you may want to anonymize host and user names).
  • If you can, check the server logs, typically in /var/log/daemon.log or /var/log/auth.log or similar.
  • If public key authentication isn't working, check the permissions again, especially the group bit (see above).

See also

6398 questions
1038
votes
14 answers

How to keep processes running after ending ssh session?

Let's say I launch a bunch of processes from a ssh session. Is it possible to terminate the ssh session while keeping those processes running on the remote machine?
978
votes
15 answers

How to get bash or ssh into a running container in background mode?

I want to ssh or bash into a running docker container. Please, see example: $ sudo docker run -d webserver webserver is clean image from ubuntu:14.04 $ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS …
592
votes
2 answers

How do I retrieve the public key from a SSH private key?

A SSH private key as generated by ssh-keygen contains a public key part. How do I retrieve this public key from the private key? I've lost my public key and need to put the contents of this public key in the servers authorized_keys file and do not…
Lekensteyn
  • 178,446
493
votes
9 answers

Easiest way to copy ssh keys to another machine?

I am lazy at home and use password authentication for my home machines. I am ready to move to key based authentication. There are many options on the web on how to do this, including catting then sshing the key over, scping the key over directly,…
Jorge Castro
  • 73,717
457
votes
3 answers

How can I break out of ssh when it locks?

I frequently ssh into my box at home from school, but usually when I change classes and my computer suspends, the pipe will be broken. However, ssh simply locks up - Ctrl+c, Ctrl+z and Ctrl+d have no effect. It's annoying to have to restart my…
Wayne Werner
  • 6,872
426
votes
7 answers

How to disable strict host key checking in ssh?

I would like to disable strict host key checking in ssh for Ubuntu 11.04. How to do it?
karthick87
  • 84,513
396
votes
11 answers

Is it possible to remove a particular host key from SSH's known_hosts file?

Is it possible to remove a particular host key from SSH's known_hosts file? I usually end up deleting the entire known_hosts file, which I have no problems with doing, but just out of curiosity, is it possible to remove just a single entry? I…
theTuxRacer
  • 16,533
382
votes
10 answers

SSH returns: no matching host key type found. Their offer: ssh-dss

I am accustomed to using Putty on a Windows box or an OSX command line terminal to SSH into a NAS, without any configuration of the client. Ubuntu 16.04 attempts to SSH into the NAS (via LAN): ssh root@192.168.8.109 Unable to negotiate with…
gatorback
  • 6,523
371
votes
10 answers

How to prevent "Write Failed: broken pipe" on SSH connection?

What can I do to configure SSH on both client and servers to prevent Write Failed: broken pipe errors? It often occurs if you sleep your client computer and resume later.
sorin
  • 10,135
340
votes
7 answers

How to run the SSH server on a port other than 22

I have two computers behind the same router. Let's call them A and B. A can SSH to B in the following manner: ssh usr@ B can SSH to A by doing the same, but the external IP must be used. I have forwarded port 22 of my router…
Gary
  • 4,042
339
votes
9 answers

How do I add SSH Keys to authorized_keys file?

I have an Ubuntu server on Amazon EC2, that I use for development, and today I stupidly cleared everything out of my ~/.ssh/authorized_keys file. Luckily I have an SSH open, so I am still connected, and can fix the file, but when I try to put my…
Dave Long
  • 3,776
322
votes
10 answers

How can I set up password-less SSH login?

I want to be able to login to a remote via ssh without having to enter the password all the time. How do I set it up? Is a different command required to execute a password-less session?
Oxwivi
  • 18,499
314
votes
20 answers

SSH connection problem with "Host key verification failed..." error

I can connect to another Ubuntu machine in my LAN via SSH. On both of then PC's I installed openssh-server but from another Ubuntu computer I can not connect to my PC via SSH and I got this error: Host key verification failed...
Navid
  • 3,353
311
votes
23 answers

SSH Permission denied (publickey)

I am trying to connect to a Linode (running Ubuntu 12.04 LTS) from my local machine (also running Ubuntu 12.04 LTS) I have created a private and public key on my local machine and copied my public key to my Linode's authorized_keys file. However,…
Pattle
  • 3,249
306
votes
7 answers

ssh: automatically accept keys

I've written this small utility script: for h in $SERVER_LIST; do ssh $h "uptime"; done When a new server is added to $SERVER_LIST, the script is stopped with: The authenticity of host 'blah.blah.blah (10.10.10.10)' can't be established. RSA key…
Adam Matan
  • 12,919
1
2 3
99 100