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
103
votes
5 answers

Paramiko's SSHClient with SFTP

How I can make SFTP transport through SSHClient on the remote server? I have a local host and two remote hosts. Remote hosts are backup server and web server. I need to find on backup server necessary backup file and put it on web server over SFTP.…
Denis
  • 7,127
  • 8
  • 37
  • 58
103
votes
8 answers

shell-init: error retrieving current directory: getcwd -- The usual fixes do not wor

I have a simple script: #!/bin/bash for server in $(~/.ansible/ansible_hosts) do ssh $server "hostname; readlink /opt/mydir/mylink;" done It works fine - the program returns the correct hostname and link - except that I get the following error…
Todd Ellner
  • 1,031
  • 2
  • 7
  • 4
102
votes
7 answers

Copying a local file from Windows to a remote server using scp

I try to transfer a folder of files from my local computer to a server via ssh and scp. After getting sudo privileges, I'm using the command as follows: scp -r C:/desktop/myfolder/deployments/ user@host:/path/to/whereyouwant/thefile However, I get…
HelloWorld
  • 4,251
  • 8
  • 36
  • 60
102
votes
10 answers

Allow user to set up an SSH tunnel, but nothing else

I'd like to allow a user to set up an SSH tunnel to a particular machine on a particular port (say, 5000), but I want to restrict this user as much as possible. (Authentication will be with public/private keypair). I know I need to edit the relevant…
Lorin Hochstein
  • 57,372
  • 31
  • 105
  • 141
102
votes
5 answers

pg_dump postgres database from remote server when port 5432 is blocked

I'm trying to pg_dump a SQL database on a remote server in our DMZ. There are 2 problems. there is not a lot of space left on the remote server so the normal command run to locally backup the database pg_dump -C database > sqldatabase.sql.bak …
Anthony McGovern
  • 1,023
  • 2
  • 8
  • 5
101
votes
6 answers

What is the best way to open remote files with emacs and ssh

I connect to the remote machine with ssh user@192.168.1.5. When I need to open a file in the remote machine I do, e.g., emacs /usr/share/nginx/html/index.html and that opens the index.html file in the shell. I noticed that some emacs commands work…
Zeynel
  • 13,145
  • 31
  • 100
  • 145
100
votes
6 answers

Sign_and_send_pubkey: no mutual signature supported

I tried to connect to ssh server in M1 macOS terminal like this ssh -i {myKeyFilePath/myKeyFile.pem} user@host but it returns sign_and_send_pubkey: no mutual signature supported user@host: Permission denied (publickey). I didn't modify any ssh…
박진근
  • 1,003
  • 2
  • 6
  • 6
99
votes
11 answers

BitBucket: Host key verification failed

I want to clone a remote repository to my local machine. I used the command: git clone git@bitbucket.org:/.git and I got the message: The authenticity of host 'bitbucket.org (104.192.143.3)' can't be established. RSA key…
CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
99
votes
4 answers

What command do I use to see what the ECDSA key fingerprint of my server is?

I see stuff all over Google on how to see the RSA key fingerprint, but not the ECDSA fingerprint.
trusktr
  • 44,284
  • 53
  • 191
  • 263
98
votes
1 answer

Avoiding SSH timeouts on Mac OS?

Every time I connect to a server with ssh, the connection is reset after a few minutes if there is no input. However, I want to remove these timeouts as to keep the connection alive for as long as possible. By looking on different forums, I saw it…
Michael Eilers Smith
  • 8,466
  • 20
  • 71
  • 106
98
votes
9 answers

access host's ssh tunnel from docker container

Using ubuntu tusty, there is a service running on a remote machine, that I can access via port forwarding through an ssh tunnel from localhost:9999. I have a docker container running. I need to access that remote service via the host's tunnel, from…
npit
  • 2,219
  • 2
  • 19
  • 25
98
votes
6 answers

How to reset or change the passphrase for a GitHub SSH key?

I have forgoten my passphrase in Git. How do I reset it? I found two solutions on Stack Overflow, but I want to know what process to follow to reset it or to get it.
Tech MLG
  • 5,777
  • 4
  • 17
  • 7
97
votes
6 answers

Git in Powershell saying 'Could not find ssh-agent'

I have git installed and it works great in the command prompt, but when I open up powershell it gives me this warning: WARNING: Could not find ssh-agent I have pageant running and loaded with my private key. This works in all the gui tools and the…
Khalid Abuhakmeh
  • 10,709
  • 10
  • 52
  • 75
97
votes
21 answers

Failed to add the host to the list of know hosts

Mac OSX Lion 10.7. In an effort to get around weird environment stuff (homebrew wasn't installing wget, and I had all sorts of weird blocks and errors), I uninstalled zschrc and homebrew and a bunch of other stuff, then installed fish shell. Now,…
Sasha
  • 6,224
  • 10
  • 55
  • 102
97
votes
4 answers

SSH SCP Local file to Remote in Terminal Mac Os X

I am attempting to copy a local file 'magento.tar.gz' from my local machine to a remote server using SSH through a VPN. This is connecting to the Virtual Machine's Internal IP which I've used as xx.x.x.xx here. I have full 'sudo' access on the SSH…
James
  • 3,233
  • 3
  • 40
  • 57