Hot answers tagged

626 votes

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

If you are on Linux system and you want connect to an SSH server on port 26 you can use the following command. ssh user@192.168.1.1 -p 26 Note: Replace server IP with the IP Address or DNS name of ...
  • 6,493
414 votes
Accepted

Ubuntu 16.04 ssh: sign_and_send_pubkey: signing failed: agent refused operation

Looks like an ssh-agent is running already but it can not find any keys attached. To solve this add the private key identities to the authentication agent like so: ssh-add Then you can ssh into your ...
  • 20.2k
370 votes
Accepted

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

The version of OpenSSH included in 16.04 disables ssh-dss. There's a neat page with legacy information that includes this issue: http://www.openssh.com/legacy.html In a nutshell, you should add the ...
  • 6,818
237 votes

Really verbose way to test Git connection over SSH?

Environment variable From Git version 2.3.0, you can use the environment variable GIT_SSH_COMMAND and pass the -v verbose argument like this: GIT_SSH_COMMAND="ssh -v" git clone example To be extra ...
  • 38.7k
137 votes
Accepted

rsync over ssh "error in protocol data stream" (code 12). ssh works

You can also get this error if you specify a remote path that doesn't exist. I got this error on OS X: $ rsync -avz public/ static:apps/myapp.com building file list ... done rsync: connection ...
  • 1,486
135 votes

"This account is currently not available" error when trying to ssh

While I agree with the others that allowing login through SSH through the www-data user is generally a bad idea, once you've logged in with a normal user it may be useful to run multiple commands ...
129 votes

SSH Permission denied (publickey)

Sometimes the issue comes from permissions and ownership. For instance, if you want to log in as root, /root, .ssh and authorized_keys must belong to root. Otherwise, sshd won't be able to read them ...
  • 1,441
122 votes

How do I copy files that need root access with scp?

Quick way From server to local machine: ssh user@server "sudo cat /etc/dir/file" > /home/user/file From local machine to server: cat /home/user/file | ssh user@server "sudo tee -a /etc/dir/file"...
118 votes

Login SSH with .ppk file on Ubuntu Terminal

If you only have .ppk file then it would be useful to create a .pem file and then connect to your server using that. In you Ubuntu computer, install putty-tools with the following command: sudo apt-...
115 votes

Progress bar for scp command

The -v switch works fine. Example: 5% 9232KB 357.5KB/s 07:48 ETA
  • 1,293
114 votes
Accepted

ssh -L (error: bind: Address already in use)

Couldn't you just kill whatever is using that port? lsof -ti:5901 | xargs kill -9 lsof -ti:5901 to find whatever is using port 5901. Pass the whole thing to kill -9 to kill whatever was using ...
  • 2,076
111 votes

Why am I getting a "port 22: Connection refused" error?

I went through this issue and finally got appropriate answer. sudo apt-get update sudo apt-get install openssh-server sudo ufw allow 22 Then went into raspi-config in a terminal window and enabled ...
  • 1,211
107 votes

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

If you came here because Bitbucket returns the following after an update to OpenSSH 8.8: Unable to negotiate with <ip address> port 22: no matching host key type found. Their offer: ssh-rsa,ssh-...
94 votes

Enter SSH passphrase once

Short answer Use AddKeysToAgent and add the following to your .ssh/config at the beginning: AddKeysToAgent yes and run git/ssh/... If it's not enough, check your ssh version and check that ssh-agent ...
  • 2,218
82 votes
Accepted

How to disable welcome message after SSH login?

The welcome messages are generated by the files residing in /etc/update-motd.d/. From man update-motd: Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at ...
  • 88.8k
81 votes

How do I SSH to machine A via B in one command?

You could use the -J command line option: ssh -J user@machineB user@machineA From man ssh: -J [user@]host[:port] Connect to the target host by first making a ssh connection to the jump ...
80 votes

/etc/sudoers file corrupted and I can't run 'pkexec visudo' over SSH

I ran into this problem also and with some digging, found a working solution. The original solution is from this github issue for NixOS by EstalillaJ. Open two ssh sessions to the target server. In ...
  • 901
79 votes

Ubuntu 16.04 ssh: sign_and_send_pubkey: signing failed: agent refused operation

I had the same problem (same symptoms) sam@xxxxx:~/.ssh$ ssh centos@123.123.123.123 sign_and_send_pubkey: signing failed: agent refused operation Permission denied (publickey,gssapi-keyex,gssapi-...
  • 901
75 votes

Login SSH with .ppk file on Ubuntu Terminal

You can convert a .ppk file in ubuntu with installing putty-tools. So apt-get install putty-tools Then youn can convert the .ppk file with puttygen to OpenSSH's format like so: puttygen <the_key....
  • 1,426
73 votes
Accepted

How does using the tilde work as a shortcut to my home directory?

~ is your home directory. ~foo is the home directory of user foo, if such a user exists, or just a directory named ~foo, if that user doesn't exist. Hence, in: scp ~Desktop/Volenteer.png jay@...
  • 189k
68 votes

Should I always restart the system when I see "System restart required"?

Should I always restart the system when prompted to? You may view the list of packages that require a restart with: more /var/run/reboot-required.pkgs Based on the list, you can decide whether it ...
67 votes
Accepted

Start SSH automatically on boot

Have you tried just simply setting sudo systemctl enable ssh ? That's how I have my ssh set to run at start up. ****I'm leaving in the above part of the answer in case it's helpful for others who ...
66 votes
Accepted

Found SSH Backdoor on VServer. What to do?

This is what you should do on all the systems that you've had this sniffer.tgz on: Nuke Them From Orbit immediately, and start over from a clean installation. (That is, destroy the system(s), ...
  • 70.4k
64 votes
Accepted

How to use existing SSH key on my newly installed Ubuntu

If you have a copy of your ssh keys (e.g., on a USB stick) then simply copy the key files to the ~/.ssh/ directory. E.g., cp /path/to/my/key/id_rsa ~/.ssh/id_rsa cp /path/to/my/key/id_rsa.pub ~/.ssh/...
  • 6,952
63 votes

Create alias for ssh connecting

Use the intended way and write the options and aliases into ~/.ssh/config: Host 1 Port 12345 User my_user HostName 123.123.123.1 Host 2 Port 12345 User my_user HostName 123.123.123.2 ...
  • 6,435
58 votes
Accepted

What is the simplest way to have remote GUI access to Ubuntu 16.04 “server” from Ubuntu 16.04 “desktop”?

ssh -X In the server you need an ssh server, for example openssh-server and at least some basic X tools, for example xinit and fluxbox (and the programs and libraries that they need). You must also ...
  • 43.7k
57 votes

How to disable welcome message after SSH login?

Another way that does not require administrative rights is to place an empty file called .hushlogin into your $HOME directory (using for example touch ~/.hushlogin). The downside to this solution is ...
  • 671
54 votes

How do I restart the SSH service?

15.04 and newer: Use this command: sudo systemctl restart ssh To restart the SSH server/daemon. Going forward with systemd starting with Ubuntu 15.04, you now use this syntax to stop, start, or ...
54 votes

Error `could not load host key` when trying to recreate SSH host keys

None of the answers above worked for me. I fixed my ubuntu system by doing the following: /usr/bin/ssh-keygen -A
  • 641

Only top scored, non community-wiki answers of a minimum length are eligible