Questions tagged [ssh]

GENERAL SSH SUPPORT IS OFF-TOPIC. Support questions may be asked on https://superuser.com. Secure Shell (SSH) is a cryptographic network protocol for secure data communication. Use this tag for programming questions related to Secure Shell. Common authentication and configuration problems are off-topic for Stack Overflow.

Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote shell services or command execution and other secure network services between two networked computers that it connects via a secure channel over an insecure network: a server and a client (running SSH server and SSH client programs, respectively). The protocol specification distinguishes two major versions that are referred to as SSH-1 and SSH-2.

SSH was designed as a replacement for Telnet and other insecure remote shell protocols such as the Berkeley rsh and rexec protocols, which send information, notably passwords, in plaintext, rendering them susceptible to interception and disclosure using packet analysis. The encryption used by SSH is intended to provide confidentiality and integrity of data over an unsecured network, such as the Internet, although files leaked by Edward Snowden indicate that the National Security Agency can sometimes decrypt SSH.

SSH uses public-key cryptography to authenticate the remote computer and allow it to authenticate the user, if necessary. There are several ways to use SSH; one is to use automatically generated public-private key pairs to simply encrypt a network connection and then use password authentication to log on.

Another is to use a manually generated public-private key pair to perform the authentication. This method allows users or programs to log in without having to specify a password. Anyone can produce a matching pair of different keys (public and private). The public key is placed on all computers that must allow access to the owner of the matching private key (the owner keeps the private key secret). Although authentication is based on the private key, the key itself is never transferred through the network during authentication. SSH only verifies whether the same person offering the public key also owns the matching private key.

In all versions of SSH it is important to verify unknown public keys, i.e. associate the public keys with identities, before accepting them as valid. Accepting an attacker's public key without validation will authorize an unauthorized attacker as a valid user.

Useful Links

Server Implementations

Client Implementations

Libraries

29979 questions
171
votes
5 answers

How do you install ssh-copy-id on a Mac?

I am having trouble trying to install ssh-copy-id on my Mac. I have tried to follow https://github.com/beautifulcode/ssh-copy-id-for-OSX but every time I run ssh-copy-id it gives me errors. Any ideas on how to get ssh-copy-id to install?
Technic1an
  • 2,697
  • 5
  • 20
  • 22
169
votes
16 answers

How to execute a MySQL command from a shell script?

How can I execute an SQL command through a shell script so that I can make it automated? I want to restore data I have collected in a SQL file using a shell script. I want to connect to a server and restore data. The command works when executed…
MUFC
  • 1,943
  • 3
  • 14
  • 13
166
votes
30 answers

git pushes with wrong user from terminal

I have an issue with git and my terminal. Here's a gallery to show you my issue. When I push commits from my terminal, git says I push them with another username, that's a user from my organization (my company) with no commit at all and it seems it…
Yinfei
  • 1,943
  • 2
  • 12
  • 13
165
votes
11 answers

Convert PEM to PPK file format

Is there a way to convert PEM files to PPK files? (you may guess that Amazon EC2 gives me a PEM file, and I need to use the PPK format for SSH connectivity).
LoneRanger
  • 1,909
  • 2
  • 13
  • 13
164
votes
10 answers

How do I mount a remote Linux folder in Windows through SSH?

I'm a blind student currently in a system admin/shell programming class. Although ssh works fine for executing commands like ls, pwd, etc editors do not work well with my screen reader and an ssh session. I was wondering if it is possible to mount a…
Jared
  • 39,513
  • 29
  • 110
  • 145
164
votes
7 answers

Git and SSH, which key is used?

Say your .ssh directory contains 30 keys (15 private and 15 public). Where in Git can one check which one is used to connect to a given remote repository?
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
163
votes
5 answers

Copy file contents to the clipboard in Linux terminal

I'm generating an SSH key but I don't know how to copy the key from id_rsa.pub to the clipboard. I'm using BackBox Linux.
Ravi Shankar
  • 2,101
  • 4
  • 14
  • 15
162
votes
1 answer

GPG vs SSH keys

On GitHub, I want to add a key to associate my computer with my account and I am given two options: create an SSH or a GPG key. What is the difference between the two keys? and is there a preferred one to use? I understand how to create both by…
Domenick
  • 2,142
  • 3
  • 12
  • 23
161
votes
17 answers

"User interaction is not allowed" trying to sign an OSX app using codesign

Our automated build is running on Jenkins. The build itself is running on slaves, with the slaves being executed via SSH. I get an error: 00:03:25.113 [codesign-app] build/App.app: User interaction is not allowed. I have tried every suggestion I…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
160
votes
9 answers

Use Expect in a Bash script to provide a password to an SSH command

I'm trying to use expect in a Bash script to provide the SSH password. Providing the password works, but I don't end up in the SSH session as I should. It goes back strait to Bash. My script: #!/bin/bash read -s PWD /usr/bin/expect <
Max
  • 12,794
  • 30
  • 90
  • 142
159
votes
22 answers

How to pass the password to su/sudo/ssh without overriding the TTY?

I'm writing a C Shell program that will be doing su or sudo or ssh. They all want their passwords in console input (the TTY) rather than stdin or the command line. Does anybody know a solution? Setting up password-less sudo is not an option. expect…
n-alexander
  • 14,663
  • 12
  • 42
  • 43
157
votes
13 answers

Copying a rsa public key to clipboard

I am trying to copy a public key to the clipboard on macOS, but I keep getting "no such file or directory." The command I am using is pasted below pbcopy < ~/.ssh/id_rsa.pub
user1850254
  • 2,091
  • 3
  • 16
  • 17
154
votes
19 answers

Git SSH error: "Connect to host: Bad file number"

I followed the git guide but I have this strange issue when trying to connect to github: $ ssh -v git@github.com OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007 debug1: Reading configuration data /c/Documents and Settings/mugues/.ssh/config debug1:…
Massimo Ugues
  • 4,373
  • 8
  • 43
  • 56
154
votes
22 answers

Composer update memory limit

I need to run composer update at my hosting so I log in with ssh and try to run the following command inside /www folder where I have Laravel and composer installation: composer update I get this error: I'm in contact with my hosting provider,…
Andrew
  • 2,128
  • 3
  • 24
  • 42
153
votes
7 answers

Bash script to set up a temporary SSH tunnel

On Cygwin, I want a Bash script to: Create an SSH tunnel to a remote server. Do some work locally that uses the tunnel. Then shut down the tunnel. The shutdown part has me perplexed. Currently, I have a lame solution. In one shell I run the…
jm.
  • 23,422
  • 22
  • 79
  • 93