How to change the ssh port connection on Windows? - windows

I am trying to connect to GitLab with an ssh key from a Windows laptop. The problem is the port of the repository has changed, and I cannot manage to change the default port 22 on the config.
I have tried with a mac laptop and it worked by editing the config file, but I cannot do the same on Windows. I created a config file with touch config and added this
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 1122
But it does not work, terminal says it is still connecting to port 22:
C:\Users\parko>ssh -T git#gitlab.com
kex_exchange_identification: read: Connection reset
C:\Users\parko>ssh -T git#gitlab.%myRepository%.com
ssh: connect to host gitlab.%myRepository%.com port 22: Connection timed out
I also tried a solution that I found in an article to change the port directly on the command when trying to connect, but it also did not work:
C:\Users\parko>ssh -T git#gitlab.%myRepository%.com:1123
ssh: Could not resolve hostname gitlab.%myRepository%.com:1123: No such host is known.
Any idea what can be happening?
Thanks in advance.

Like #ewong said, I had to add the port with the -p parameter instead of at the end of the command
ssh -p [port number] -T git#[gitlab URL]
for me it was:
C:\Users\parko>ssh -p 1123 -T git#gitlab.%myRepository%.com

Related

Set up SSH tunnel with PgAdmin 4

I am new to pgAdmin and to SSH tunnels. I am trying to establish a connection to a postgres DB with SSH tunnel. I am on Windows 10. I am given the following instructions (I changed all the names and ports in the below)
Add the following to your SSH config (~/.ssh/config):
Host prod
Hostname myorg.org.uk
User sshusername
IdentityFile idef.pem
LocalForward 9999 localforward.amazonaws.com:8888
Now you can tunnel your way through to PostgreSQL:
ssh -N prod
And now psql et al can connect (You must open a new Terminal window while the SSH tunnel is running):
psql -h localhost -p 9999 -U connectionusername -d dproduction
I am also given the dproduction database password for the database I am trying to connect to: dproduction_pwd
I don't understand where everything goes in pgAdmin. I did the following:
Create-Server:
Name = test
Connection:
Host Name/Address: localhost
Prot: 9999
Maintenance database: postgres
username: connectionusername
SSH Tunnel:
Tunnel host: myorg.org.uk
Tunnel post: 9999
username: sshusername
Identity file: C:\idef.pem
Password: dproduction_pwd
I must be doing something wrong, as I don't use LocalForward from the ssh config above, where does this go? putting it in Tunnel host does not work.
I managed to use SSH tunnel to access my database with Windows 10 SSH and PGAdmin SSH Tunnel. It did take a while. pgAdmin's document isn't very clear on this. Here's the difference I found:
When setting SSH tunnel with Windows 10 SSH, you need to forward a local port (9999 in your case) to the remote port (8888).
In pgAdmin, that local port is no longer needed. My guess is since it already knows you want to access which service through which tunnel, it takes care of the local port in the background. That tunnel port, in the most common cases, should be the SSH port 22.
My suggested changes to your current setting would be:
in SSH Tunnel tab, set Tunnel port to 22
in Connection tab, set Port to 8888
This should work.

scp to a remote server; ssh: connect to host server#address.it port 22: Connection timed out

I'm having some trouble to use scp command in order to copy some file in a remote server.
the line i write on the terminal is
scp file.dat server#address.it:home/folder
and after about a minute it says the connection is lost due to time out
using the option -vvv I get
Executing: program /usr/bin/ssh host server#address.it, user username, command scp -v -t home/folder
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "server#address.it" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to server#address.it [141.108.1.185] port 22.
debug1: connect to address 141.108.1.185 port 22: Connection timed out
ssh: connect to host server#address.it port 22: Connection timed out
lost connection
Seaching on the web, I found that the most common source for this problem are firewalls, but I checked them and it seems they are ok. Indeed I have
sudo ufw status
Stato: attivo
A Azione Da
- ------ --
22/tcp ALLOW Anywhere
22 ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
One last information, if I try to make the access to the remote server from my PC terminal using ssh, there are no problems, and there I have done simple operations like creating folders (not much more for now, since I have to copy some data from my PC to that server to work on it)
As you well said, normally a timeout means a network or communication issue between the source and the target. I would run:
In the source server
Windows --> CMD --> tracert -h 30 -w 60 -4 IPaddressOFTarget
Linux --> Terminal --> traceroute -4 -w 30 IPaddressOFTarget
Provide the output.
Regards
On DEBIAN 10 this is working fine:
scp -r -P 2222 /DIRFILES remote-user#remote-host:/DIRFILES
-r recursive
-P remote port
DIRFILES absolute path to folders

How to use an remote instance as "proxy" to ssh port

In my local network I currently can't ssh to bitbucket:
telnet bitbucket.org 22 fails.
But I can ssh to an remote ubuntu instance that can ssh to bitbucket (the command above works).
How can I configure my connectivity to make my traffic to bitbucket port (22) go through this intermediary instance?
I tried running the command below but did not work:
sudo ssh -i mykey -N -L 22:remote_instance:22 ubuntu#remote_instance (ps: remote_instance can access bitbucket with port 22).
Thanks :)

Bash Ubuntu on Windows 10, connect to host port 22: Connection Failure

I just installed the Bash Ubuntu on Windows 10 natively. When I try and acess a remote server I get ssh: connect to host HOSTNAME port 22: Connection refused
I have tried to find a solutions, but the solutions doesn't work.
This is what I have tried:
https://askubuntu.com/questions/59458/error-message-sudo-unable-to-resolve-host-user/733120#733120
When I could not acess /etx/hosts I tried this:
https://askubuntu.com/questions/326239/cannot-access-etc-hosts
After downloading gksudo to try and edit /etc/hosts I got this error message (gksudo:2601): Gtk-WARNING **: cannot open display:
Are u sure everything is correctly setup?
I just tried
ssh -T git#github.com
in my Bash on Ubuntu on Windows.
and it totally works Returning
Hi <usernamer>! You've successfully authenticated, but GitHub does not provide shell access.
Maybe you have some settings that prevent connections? for example in ~/.bashrc?
Maybe your server needs a different port? use ssh -p 2222 for that.

Setup passphraseless ssh to localhost on OS X

I'm trying to get Hadoop's Pseudo-Distributed Operation example (http://hadoop.apache.org/common/docs/stable/single_node_setup.html) to work on OS X Lion, but am having trouble getting the ssh to work without a passphrase.
The instructions say the following:
Setup passphraseless ssh
Now check that you can ssh to the localhost without a passphrase: $
ssh localhost
I'm getting connection refused:
archos:hadoop-0.20.203.0 travis$ ssh localhost
ssh: connect to host localhost port 22: Connection refused
If you cannot ssh to localhost without a passphrase, execute the
following commands:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
After this step I am still getting connection refused. Any ideas???
Sounds like you don't have SSH enabled. Should be in the network settings control panel somewhere.
You go to "System Preferences > Sharing > Remote Access" and there's a list of authorized users. Change it to "All Users".
That's solves this problem.
Check the permissions on your .ssh directory. Some ssh implementations require that the directory be chmod 700. Otherwise, they just ignore it.
Also, check the output of
ssh -v localhost
to see how the ssh client is trying to connect. The output is very detailed, and will help you decide if it's an authentication problem.
I had the same issue.
Please check if the ssh server is running or not.
If yes, open the /etc/init.d/ssh_config and /etc/init.d/sshd_config files. The issue is that the server is running on a different port and the client is pointing to different port.
Before this please ensure that openssh-server and client are installed.
I had the same problem and i solved it the following manner :
SSH is activated.
ssh -v localhost (as stated by Herko)
In the ouput, i identified that the authentication method by DSA is not supported.
debug1: Skipping ssh-dss key /Users/john/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
I simply re-generate an ECDSA keys and remove the DSA key pairs.
After the keys generation, the procedure given on Hadoop documentation holds.
Therefore, it is important to check, if the authentication method is supported by the Openssh configuration.

Resources