Questions tagged [ssh]

SSH (Secure SHell) is a protocol for securely running commands on a remote computer. Use this tag for questions about configuring, using and trouble-shooting SSH client and server software.

SSH is a protocol for securely running commands on a remote computer. It works by creating an encrypted connection between a client and a server listening on port 22 (by default). It was designed in the mid 1990s as a secure replacement for protocols such as Telnet and FTP which exchange data (including authentication tokens) in plain text.

Implementations

  • Dropbear is a lightweight implementation of SSH targeted at embedded devices.
  • OpenSSH, developed by the OpenBSD project, is by far the most common implementation of SSH, both server-side and client-side, in the unix world. If someone mentions SSH in a unix context, assume OpenSSH unless told otherwise.
  • PuTTY is an SSH client mostly found on Windows.

Related programs

  • AutoSSH: Automatically restart SSH sessions and tunnels
  • Corkscrew: tunnel through HTTP proxies
  • SSHFS: mount remote filesystems over SSH

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:

  • The most useful source of information for diagnosing problems with SSH connections is the messages logged by the SSH server. These are typically logged to /var/log/secure, /var/log/auth.log, /var/log/daemon.log or similar, depending on the OS/distribution. Relevant log messages should be included in in the question.
  • If you can’t access the server to check the logs, the next best option is to run ssh -vvv to see a lot of debugging output from the client’s perspective. 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 public key authentication isn't working, check the permissions again, especially the group bit (see above).

Further reading

8049 questions
314
votes
6 answers

Multiple similar entries in ssh config

Say I want to configure my ssh options for 30 servers with the same setup in my .ssh config file: host XXX HostName XXX.YYY.com User my_username Compression yes Ciphers arcfour,blowfish-cbc Protocol 2 ControlMaster…
203
votes
5 answers

Is it possible to find out the hosts in the known_hosts file?

I would like to see what hosts are in my known_hosts file but it doesn't appear to be human readable. Is it possible to read it? More specifically there is a host that I can connect to via several names and I want to find out what the fingerprint I…
Colin Newell
  • 2,133
183
votes
9 answers

What does the Broken pipe message mean in an SSH session?

Sometimes my SSH session disconnects with a Write failed: Broken pipe message. What does it mean? And how can I keep my session open? I know about screen, but that's not the answer I'm looking for. I think this is a sshd config option.
181
votes
8 answers

Get SSH server key fingerprint

Is there a way to programmatically obtain a SSH server key fingerprint without authenticating to it? I'm trying ssh -v user@host false 2>&1 | grep "Server host key", but this hangs waiting for a password if key based auth is not setup.
loopbackbee
  • 4,602
136
votes
10 answers

How can I keep my SSH sessions from freezing?

I have ServerAliveInterval and in case of few machines also ClientAliveInterval set to 540 in SSH client/server configuration files (I suppose setting it to more than that would not be a good idea). I work with many SSH sessions which currently…
syntagma
  • 12,311
125
votes
12 answers

ssh_exchange_identification: read: Connection reset by peer

I am on OS X trying to ssh into a ubuntu 12.04 server. I was able to SSH in -- until abruptly stuff stopped working. I've read online to use the -v to debug this. Output is shown below. If I ssh into a different box and then ssh from that box to the…
bernie2436
  • 6,655
118
votes
10 answers

Is it possible to run ssh-copy-id on port other than 22?

I have a server with SSH running on a non-standard port. Instead of 22, it runs on 8129. To log in, I use: ssh -p 8129 hostname Now, whenever I need to set up a key for password-less login, I have to copy the public key and add it to…
106
votes
7 answers

ssh unable to negotiate - no matching key exchange method found

I am trying to log in to my DSL router, because I'm having trouble with command-line mail. I'm hoping to be able to reconfigure the router. When I give the ssh command, this is what happens: $ ssh enduser@10.255.252.1 Unable to negotiate with…
j0h
  • 3,617
78
votes
3 answers

Terminate dropped SSH sessions

My SSH sessions seem to be dropping though that is not my major problem - the major problem is my previous sessions are still alive, worse yet one of them is running visudo preventing me from accessing it! who shows a number of sessions all except…
markmnl
  • 1,051
72
votes
3 answers

Using an already established SSH channel

I have an already established ssh connection between two machines. Is there a way to send commands to the remote machine from a shell script that is run on the local machine, using the already open connection, and without starting another ssh…
SWeko
  • 823
65
votes
2 answers

How can I make ssh ignore .ssh/config?

I have the following in my ~/.ssh/config. HOST 10.2.192.* USER foo PreferredAuthentications publickey IdentityFile ~/.ssh/foo/id_rsa The above configuration lets me connect to a machine while typing half as many words. …
spuder
  • 18,053
60
votes
6 answers

Trying to SSH into server and getting key_load_public: No such file or directory error

I created a passwordless ssh connection to my remote server from my mac. It worked(!) and then I closed my terminal, re-opened it, tried again, and got the following (username, my_ip are not real): ssh -vvv username@my_ip OpenSSH_7.2p2, LibreSSL…
Eric
  • 715
60
votes
7 answers

How do you copy the public key to a ssh-server?

Here is what I have tried, and I got an error: $ cat /home/tim/.ssh/id_rsa.pub | ssh tim@just.some.other.server 'cat >> .ssh/authorized_keys' Password: cat: >>: No such file or directory cat: .ssh/authorized_keys: No such file or directory
Tim
  • 101,790
56
votes
19 answers

ssh prompts for password despite ssh-copy-id

I've been using public key authentication on a remote server for some time now for remote shell use as well as for sshfs mounts. After forcing a umount of my sshfs directory, I noticed that ssh began to prompt me for a password. I tried purging the…
53
votes
6 answers

Tell SSH to use a graphical prompt for key passphrase

How can I force SSH to request passphrases using a graphical prompt (GTK, for example) instead of the standard one that uses the terminal? I tried setting SSH_ASKPASS=/usr/bin/ssh-askpass but it seems to have no effects. The problem is the fact the…
gioele
  • 2,139
1
2 3
39 40