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
440
votes
6 answers

How do I verify/check/test/validate my SSH passphrase?

I think I forgot the passphrase for my SSH key, but I have a hunch what it might be. How do I check if I'm right?
joachim
  • 28,554
  • 13
  • 41
  • 44
439
votes
3 answers

Copying files using rsync from remote server to local machine

Once I've ssh'd into my remote server, what would the command be to copy all files from a directory to a local directory on my machine?
markstewie
  • 9,237
  • 10
  • 50
  • 72
439
votes
6 answers

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058"

When I try to start the ssh-agent on Windows 10 via PowerShell (with elevated right or without) by entering Start-Service ssh-agent I get the error unable to start ssh-agent service, error :1058 When I check of the service is running via…
quervernetzt
  • 10,311
  • 6
  • 32
  • 51
427
votes
49 answers

Vagrant stuck connection timeout retrying

My vagrant was working perfectly fine last night. I've just turned the PC on, hit vagrant up, and this is what I get: ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... …
Kiee
  • 10,661
  • 8
  • 31
  • 56
424
votes
5 answers

Keep SSH session alive

I use ssh -p8520 username@remote_host to login remote server. Issue: It is always connected and works properly when I am in the work place. Unfortunately, terminal freezes in 10 - 15 minutes after I connected with the remote server from home.…
Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125
411
votes
9 answers

git remote add with other SSH port

In Git, how can I add a remote origin server when my host uses a different SSH port? git remote add origin ssh://user@host/srv/git/example
JuanPablo
  • 23,792
  • 39
  • 118
  • 164
408
votes
12 answers

Start ssh-agent on login

I have a site as a remote Git repo pulling from Bitbucket.com using an SSH alias. I can manually start the ssh-agent on my server but I have to do this every time I login via SSH. I manually start the ssh-agent: eval ssh-agent $SHELL Then I add the…
Pathsofdesign
  • 4,678
  • 5
  • 18
  • 26
394
votes
24 answers

Is it possible to create a remote repo on GitHub from the CLI without opening browser?

I created a new local Git repository: ~$ mkdir projectname ~$ cd projectname ~$ git init ~$ touch file1 ~$ git add file1 ~$ git commit -m 'first commit' Is there any git command to create a new remote repo and push my commit to GitHub from here? I…
anddoutoi
  • 9,973
  • 4
  • 29
  • 28
384
votes
31 answers

ssh: connect to host github.com port 22: Connection timed out

I am under a proxy and I am pushing in to git successfully for quite a while. Now I am not able to push into git all of a sudden. I have set the RSA key and the proxy and double checked them, with no avail and git is throwing me the error shown in…
Vihari Piratla
  • 8,308
  • 4
  • 20
  • 26
362
votes
19 answers

Getting ssh to execute a command in the background on target machine

This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just…
dagorym
  • 5,695
  • 3
  • 25
  • 23
360
votes
17 answers

SSH to Elastic Beanstalk instance

I just signed up for Amazon's new Elastic Beanstalk offering. What I can't figure out is how to SSH to a Beanstalk instance. I don't have a private key because Beanstalk generated the instance on my behalf.
Thomas D
  • 3,705
  • 3
  • 15
  • 4
355
votes
29 answers

Permission denied (publickey) when SSH Access to Amazon EC2 instance

I want to use my Amazon ec2 instance but faced the following error: Permission denied (publickey). I have created my key pair and downloaded .pem file. Given: chmod 600 pem file. Then, this command ssh -i…
Kashiftufail
  • 10,815
  • 11
  • 45
  • 79
338
votes
9 answers

How do I get git to default to ssh and not https for new repositories

These days when I create a new repository on GitHub on the setup page I get: git remote add origin https://github.com/nikhilbhardwaj/abc.git git push -u origin master And whenever I have to push a commit I need to enter my GitHub username and…
nikhil
  • 8,925
  • 21
  • 62
  • 102
337
votes
6 answers

SSH configuration: override the default username

Is it possible to configure ssh to know what my username should be? By default it uses the current username, which is not correct in my case. I'm on a loaner laptop, and my username is loaner, but I want to tell ssh that my username is buck. Bonus…
bukzor
  • 37,539
  • 11
  • 77
  • 111
333
votes
15 answers

How can I ssh directly to a particular directory?

I often have to login to one of several servers and go to one of several directories on those machines. Currently I do something of this sort: localhost ~]$ ssh somehost Welcome to somehost! somehost ~]$ cd…
Frosty
  • 6,213
  • 3
  • 24
  • 20